Skip to content

Stop the scan-cancel test racing a fast Release scan - #10

Merged
HeathHowren merged 1 commit into
masterfrom
fix/lua-cancel-scan-test-race
Aug 25, 2026
Merged

Stop the scan-cancel test racing a fast Release scan#10
HeathHowren merged 1 commit into
masterfrom
fix/lua-cancel-scan-test-race

Conversation

@HeathHowren

@HeathHowren HeathHowren commented Aug 25, 2026

Copy link
Copy Markdown
Owner

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

  • The script parks in a loop of its own rather than in scan_wait, so it cannot finish by itself.
  • The test waits for scanJob().progress().running to actually become true before cancelling, instead of sleeping and assuming.
  • REQUIRE(console.running()) now establishes the premise the old test never checked.
  • The final assertion moves from "did the script print" to the scan's own status, which tells a cancelled scan ("Scan cancelled") apart from one that completed. ScanJob::cancel joins its worker, so the scan is over by the time cancel() returns either way — checking running alone 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

  • Rewritten test run 12× in Release: clean.
  • Full suite 5× consecutively in Release (495 test executions): 99/99 every time.
  • Debug and Release both build warning-clean under /W4 /WX and pass 99/99.
  • Old test re-verified failing 2/6 in Release to confirm the diagnosis rather than assume it.

Needed on master before v2.1.0 can be tagged, since the tag build runs the same suite.

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>
@HeathHowren
HeathHowren merged commit 2c2a614 into master Aug 25, 2026
4 checks passed
@HeathHowren
HeathHowren deleted the fix/lua-cancel-scan-test-race branch August 25, 2026 01:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant