Repository navigation
test: make the automation clock tests deterministic - #149
Merged
Merged
Conversation
The core clock is the wall time read when the workspace opens, moved on by the executor's elapsed time. The one-time automation test compared the due time to wall time read around the click, so any real gap between the workspace opening and the click made it fail. The test now reads the same clock through Workspace::clock_now, so the window matches what the core used. The three-failed-runs test waited a fixed 20 steps for the pause. It now polls for the AutomationPaused event, up to 200 steps, and stops as soon as the event arrives.
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.
Cause
One-time automation test. The core's clock is the wall time read when the workspace opens, plus the test executor's elapsed time. The test compared the due time to wall time read around the click. Any real gap between opening and clicking pushed the due time below the lower bound. CI run 43202985106 (Linux):
due at 1794481025314, expected one minute after 1794480966747..1794480967205.Failed-runs test. It waited a fixed 20 steps of fake time for the pause. The pause write runs on a real thread, so the fixed count did not wait for it.
Fix
Workspace::clock_nowis the one clock.time()uses it, and the test reads it before and after the click. The widened 59 000 ms bound is gone.AutomationPausedevent throughpause_heard. It polls with a short real sleep, up to 200 times, and stops as soon as the event arrives.Proof
due at 1794521547498, expected one minute after 1794521489201..1794521489237). The new one passes with the same pause.cargo fmt --check,cargo clippy --workspace --all-targets --locked -- -D warnings, andscripts/size-budget.sh(83238 of 83244) all pass.Not proven
runs_with_status) uses real child processes and the 500 ms drain, and this PR does not change it. If it flakes again, look there first.