test: de-flake StopTimer_prevents_further_callbacks (#250) - #307
Merged
Conversation
The test asserted an exact callback-count equality after only a fixed 50ms grace following StopTimer(). A tick already dispatched when StopTimer was called (at most one) can land after that grace on a slow/loaded runner, incrementing the count and failing the exact-equality assertion. Replaces the fixed grace with a WaitUntilStable poll that returns once the count has been unchanged for a full window — so the last in-flight tick is absorbed regardless of runner speed — then still asserts the count stays put across several further intervals (a running timer would fire ~4 more). Bounded by an overall deadline so a genuinely-broken StopTimer fails the assertion instead of hanging. Verified: 5/5 green in Release. Closes #250 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Merged
This was referenced Jul 24, 2026
This was referenced Aug 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SystemProgressTimerTests.StopTimer_prevents_further_callbacksis flaky on slow runners (issue #250). It asserted exact count equality (countAfterStop == countAfterWait) after only a fixed 50ms grace followingStopTimer(). A tick already dispatched whenStopTimerwas called — at most one — can land after that grace when the runner is slow/loaded, incrementing the count and failing the equality.Fix: replace the fixed grace with a
WaitUntilStablepoll that returns once the callback count has been unchanged for a full stability window — absorbing that last in-flight tick regardless of runner speed — then still assert the count stays put across several further intervals (a running timer would fire ~4 more). The poll is bounded by an overall deadline, so a genuinely-brokenStopTimerfails the assertion rather than hanging.No production code change; the timer behaviour under test is unchanged — only the test's timing assumptions are made deterministic.
Verification
Ran the test 5× in Release (net10.0) — green every time.
Closes #250