From 80d4087583956f104a807d4003361fdb83121413 Mon Sep 17 00:00:00 2001 From: 7schmiede Date: Fri, 23 Oct 2026 23:37:26 +0200 Subject: [PATCH] test(proc): the macOS CPU time test waits for the ticks to move `the_machine_reports_memory_and_cpu_time` read the host's CPU ticks 300 ms apart and wanted them to have moved; on the macOS runner (a virtual machine) they had not (`64558 -> 64558`, check on macos-14 in #254). It now stays busy until they move, at least 300 ms and at most 5 s. Co-Authored-By: Claude Opus 5.5 --- crates/devstack-proc/src/macos.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/crates/devstack-proc/src/macos.rs b/crates/devstack-proc/src/macos.rs index f721f8e4..8c165ca0 100644 --- a/crates/devstack-proc/src/macos.rs +++ b/crates/devstack-proc/src/macos.rs @@ -302,11 +302,18 @@ mod tests { let free = memory_available().unwrap(); assert!(free > 0 && free <= total, "{free} of {total}"); let (idle1, total1) = cpu_times().unwrap(); + // Busy until the ticks move: on a virtual machine (CI) the host + // counts them in steps, 300 ms could see none. let t0 = Instant::now(); - while t0.elapsed() < Duration::from_millis(300) { + let (idle2, total2) = loop { std::hint::black_box(t0.elapsed()); - } - let (idle2, total2) = cpu_times().unwrap(); + let now = cpu_times().unwrap(); + if (now.1 > total1 && t0.elapsed() >= Duration::from_millis(300)) + || t0.elapsed() > Duration::from_secs(5) + { + break now; + } + }; assert!(total2 > total1, "{total1} -> {total2}"); assert!(idle2 >= idle1 && idle2 - idle1 <= total2 - total1); }