Repository navigation
test(core): freeze the wait clock in two timeout tests and let the scheduler sleep on it - #49
Merged
Merged
Conversation
…heduler sleep on it Two wait_event tests gave wait_for_event a 20 ms deadline on the wall clock and then asserted on the last poll error. On a loaded runner the deadline passed before the first poll, so last_error was null (fork CI on 9637e8b). Both now freeze the virtual clock, as their neighbour already does. Freezing exposed that WaitScheduler::wait slept with std::thread::sleep, so virtual time never advanced and the test looped. It now sleeps through wait::deadline::sleep, which is std::thread::sleep outside tests, so shipped behaviour is unchanged.
This was referenced Nov 8, 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.
What and why
Update after merging main: #45 (24574e9) already froze the clock in
failed_inventory_poll_never_diffs_against_an_empty_baseline. Against main this PR now changes two lines. It freezes the clock inretryable_seed_inventory_failure_is_preserved_in_timeout_evidence, and it makesWaitScheduler::waitsleep on the test-aware clock, which that freeze needs (without it the test loops forever).Two
wait_eventtests set a 20 ms deadline on the wall clock and then asserted on the last poll error:failed_inventory_poll_never_diffs_against_an_empty_baselineretryable_seed_inventory_failure_is_preserved_in_timeout_evidenceOn a loaded runner the deadline passed before the first poll, so
last_errorwas null. This failed the macOS Test job on #6 (9637e8b), which doesn't touch this code. Main had passed the same test on 921d6d2.Both tests now freeze the virtual clock, as their neighbour
failed_inventory_poll_never_reports_app_terminationalready does.Freezing exposed a second problem:
WaitScheduler::waitslept withstd::thread::sleep, so virtual time never advanced and the frozen test looped forever. It now sleeps throughwait::deadline::sleep. Outsidecfg(test)that function isstd::thread::sleep, so shipped behaviour is unchanged.How tested
All runs went through the bench's serialized cargo wrapper on macOS.
cargo build --tests -p agent-desktop-core: ok.cargo test -p agent-desktop-core --lib wait: 289 passed, 0 failed.cargo clippy -p agent-desktop-core --all-targets -- -D warnings: clean.cargo fmt --all -- --check: clean.check-rust-file-size.sh,check-no-phase-references.sh,check-stale-ref-constructor-misuse.shandcheck-architecture.sh: pass.retryable_seed_inventory_failure_is_preserved_in_timeout_evidencehangs. It ran past 60 s and was stopped at 1200 s. With the change restored, 36wait_eventtests pass in 1.08 s.Risks
WaitScheduler::waitnow callswait::deadline::sleep. Non-test builds compile it to the samestd::thread::sleep.Left
Nothing.