From 99da7e25684c5f4f1ea71d183cdb26c6b3d40c43 Mon Sep 17 00:00:00 2001 From: Jason Luker <176962611+ZJHeepfixer@users.noreply.github.com> Date: Sun, 25 Oct 2026 03:36:06 -0700 Subject: [PATCH] Footage watcher host test: wait for each wake before taking its stamps The worker stores a report and then wakes the interface; the test took the report as soon as it was there and asserted the wake count right after, which can run before the wake. `next` now waits for the n-th wake and then takes the stamps, as the engine tests' `wait_for` does. Checked with 50 ms between the worker's report and its wake: this test passes; the previous one fails at `wakes == 1`. Co-Authored-By: Claude Opus 5.5 --- crates/host/tests/it/footage_reload.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/crates/host/tests/it/footage_reload.rs b/crates/host/tests/it/footage_reload.rs index 323087906..876c543ec 100644 --- a/crates/host/tests/it/footage_reload.rs +++ b/crates/host/tests/it/footage_reload.rs @@ -171,10 +171,14 @@ fn the_watcher_notices_a_footage_file_changed_on_disk() { .unwrap(); w.set_focused(true); w.set_watched(footage_reload::watched(&s)); - let next = |w: &footage_reload::Watcher| { + // Report `n`: the worker stores the stamps and then wakes the interface, so wait for the + // wake too, not only for the stamps. + let next = |w: &footage_reload::Watcher, n: usize| { let t0 = Instant::now(); loop { - if let Some(stamps) = w.take() { + if wakes.load(Ordering::SeqCst) >= n + && let Some(stamps) = w.take() + { return stamps; } assert!(t0.elapsed() < Duration::from_secs(10), "the watcher never reported"); @@ -182,14 +186,14 @@ fn the_watcher_notices_a_footage_file_changed_on_disk() { } }; // First look: remembered, nothing to reload. - assert_eq!(footage_reload::apply_stamps(&mut s, next(&w)).unwrap(), json!({"files": 0, "reloaded": 0})); + assert_eq!(footage_reload::apply_stamps(&mut s, next(&w, 1)).unwrap(), json!({"files": 0, "reloaded": 0})); assert_eq!(wakes.load(Ordering::SeqCst), 1); std::thread::sleep(fast * 15); assert!(w.take().is_none(), "an unchanged file is never reported"); assert_eq!(wakes.load(Ordering::SeqCst), 1, "and never wakes the interface"); // Saved in another app: reported once, reloaded, shown. save(&path, &flat(GREEN, true)); - assert_eq!(footage_reload::apply_stamps(&mut s, next(&w)).unwrap(), json!({"files": 1, "reloaded": 1})); + assert_eq!(footage_reload::apply_stamps(&mut s, next(&w, 2)).unwrap(), json!({"files": 1, "reloaded": 1})); assert!(near(pixel(&s, cid, 32, 24), GREEN)); assert_eq!(wakes.load(Ordering::SeqCst), 2); std::thread::sleep(fast * 10);