Stop the scan-cancel test racing a fast Release scan - #10
Merged
Conversation
The test scanned, waited and printed, slept 150 ms, then cancelled and checked that the script had not reached its print. An unknown-value scan of the test helper takes a few milliseconds in a Release build, so the script routinely finished on its own before the sleep expired: the cancel arrived with nothing left to cancel and the print had already happened. It passed in Debug, where the scan is slow enough, and failed in Release -- 2 runs in 6 locally, and the merge of v2.1.0 on CI. The script now parks in a loop of its own instead of in scan_wait, and the test waits for the scan to actually be in flight rather than assuming a sleep is long enough. Because the loop has no exit, only the cancel can end the script. The final check moves from "did the script print" to the scan's own status, which distinguishes a scan that was cancelled from one that ran to completion -- ScanJob::cancel joins its worker, so the scan is over by the time cancel returns either way and checking `running` alone could never have failed. Release suite run 5x clean; Debug and Release both 99/99. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Why
The v2.1.0 merge went red on
master:Build and test (Release)failed on test 85, Cancelling a script also cancels the scan it started. Debug passed.The test was timing-dependent. It submitted a script that scanned, waited and printed, slept 150 ms, cancelled, and then checked the script had not reached its print. An unknown-value scan of the test helper takes a few milliseconds in a Release build, so the script routinely ran to completion before the sleep expired — the cancel arrived with nothing left to cancel, and the print had already happened.
This is not CI-specific. On the same commit, built locally in Release, the old test fails 2 runs in 6. It only ever passed because Debug is slow enough.
What
scan_wait, so it cannot finish by itself.scanJob().progress().runningto actually become true before cancelling, instead of sleeping and assuming.REQUIRE(console.running())now establishes the premise the old test never checked."Scan cancelled") apart from one that completed.ScanJob::canceljoins its worker, so the scan is over by the timecancel()returns either way — checkingrunningalone could never have failed, and the old test's strongest claim was the one that raced.No production code changed. This is a test-only fix.
Tests
/W4 /WXand pass 99/99.Needed on
masterbeforev2.1.0can be tagged, since the tag build runs the same suite.