Repository navigation
test: make ExampleBlocking and Delay GetWait test deterministic - #94
Merged
Merged
Conversation
…Wait ExampleBlocking printed the goroutine's measured wait rounded to the millisecond and expected exactly "1ms". The value is sleep plus wake-up latency, so on Windows, where Sleep overshoots by half a millisecond or more, it rounds to "2ms" and the example fails (#92). It also Peeked after Offer while a woken GetWait goroutine raced for the lock; under GOMAXPROCS=10 Peek observed an empty queue about 1 in 20000 runs. Rewrite the example without timing: Peek while the initial head is present, show Get erroring on the empty queue, then show GetWait receiving the offered element through a channel. The output is now independent of scheduling. TestDelay/GetWait/WakesAfterDeadline measured elapsed time from a clock reading taken after the deadline was computed, so under load it could fall a few microseconds short of 20ms although GetWait woke on time (2/15 failures with atomic coverage under CPU contention). Compare the return time against the deadline itself instead. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The coverage job stays Linux-only; a separate non-blocking matrix job runs the race-enabled suite on windows-latest and macos-latest so platform-specific timing and scheduler differences surface in CI instead of in contributors' local runs (#92). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #94 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 6 6
Lines 552 552
=========================================
Hits 552 552
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
ExampleBlockingasserted on a wall-clock measurement (received after 1ms), which Windows timer overshoot rounds to2ms; it alsoPeeked afterOfferwhile the wokenGetWaitgoroutine raced for the lock, which lost about 1 in 20000 runs locally at GOMAXPROCS=10. The example is rewritten with no timing at all:Peekruns while the initial head is present,Getis shown erroring on the empty queue, andGetWaithands its element back over a channel, so the output no longer depends on scheduling. Stress-testing the suite also exposedTestDelay/GetWait/WakesAfterDeadlinemeasuring elapsed time from a second clock reading taken after the deadline was computed, which fails under load by a few microseconds; it now compares the return time to the deadline itself. The queue code is untouched.Verified locally with 40 full-suite runs under race, shuffle and atomic coverage with four busy loops competing for CPU: 0 failures, down from 2 in 15 before the Delay fix. Coverage stays at 100%.
A second, non-blocking CI job now runs the race-enabled suite on
windows-latestandmacos-latest, so this PR's own checks are the first Windows verification of the fix. The requiredTestjob is unchanged.Closes #92