From 7cfd7eebf4302948602489d11124d2d460b19493 Mon Sep 17 00:00:00 2001 From: flash2do Date: Sun, 8 Nov 2026 03:54:27 -0800 Subject: [PATCH] test(core): freeze the wait clock in two timeout tests and let the scheduler 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 9637e8b7). 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. --- crates/core/src/commands/wait_event_tests.rs | 2 ++ crates/core/src/commands/wait_scheduler.rs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/core/src/commands/wait_event_tests.rs b/crates/core/src/commands/wait_event_tests.rs index 3a428067a1..261a66eea7 100644 --- a/crates/core/src/commands/wait_event_tests.rs +++ b/crates/core/src/commands/wait_event_tests.rs @@ -275,6 +275,7 @@ fn seeded_baseline_failure_is_not_disguised_as_timeout() { #[test] fn retryable_seed_inventory_failure_is_preserved_in_timeout_evidence() { + let _clock = crate::wait::deadline::VirtualClock::freeze(); let adapter = SequenceAdapter::new(vec![empty_baseline()]); let seed_error = AdapterError::app_unresponsive("macOS inventory").with_details(json!({ "kind": "inventory_sources", @@ -298,6 +299,7 @@ fn retryable_seed_inventory_failure_is_preserved_in_timeout_evidence() { #[test] fn failed_inventory_poll_never_diffs_against_an_empty_baseline() { + let _clock = crate::wait::deadline::VirtualClock::freeze(); let adapter = FailingInventoryAdapter { calls: std::sync::Mutex::new(0), }; diff --git a/crates/core/src/commands/wait_scheduler.rs b/crates/core/src/commands/wait_scheduler.rs index 25d6065f99..32a63760b7 100644 --- a/crates/core/src/commands/wait_scheduler.rs +++ b/crates/core/src/commands/wait_scheduler.rs @@ -31,6 +31,6 @@ impl WaitScheduler { self.wakeup = None; return; } - std::thread::sleep(poll.remaining()); + crate::wait::deadline::sleep(poll.remaining()); } }