From 4280f83bb0be01158ef843f73508aac53b29aa2e Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Sat, 10 Oct 2026 08:14:40 -0400 Subject: [PATCH] Tests: the viewer find test waits for results by a deadline, not a frame count Under a full workspace test run the background find could still be searching after 60 short frames: 12 of 15 matches were in when the assertion ran. The PAGE re-run had the same race. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/tests/viewer.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/tests/viewer.rs b/crates/ui-egui/tests/viewer.rs index 46c04cc0f..9f560c81c 100644 --- a/crates/ui-egui/tests/viewer.rs +++ b/crates/ui-egui/tests/viewer.rs @@ -108,7 +108,10 @@ fn view_history_select_all_and_find_options() { h.state_mut().views[0].open_find(); h.state_mut().views[0].find.as_mut().unwrap().query = "page".into(); h.state_mut().views[0].rerun_find(); - for _ in 0..60 { + // Find runs in the background: wait for it by a deadline, not a frame count, which a loaded + // machine (the whole workspace testing at once) can use up before the last page is searched. + let deadline = std::time::Instant::now() + std::time::Duration::from_secs(20); + while std::time::Instant::now() < deadline { h.run_steps(2); std::thread::sleep(std::time::Duration::from_millis(5)); if h.state().views[0].find.as_ref().unwrap().matches.len() >= 15 { @@ -126,7 +129,11 @@ fn view_history_select_all_and_find_options() { assert_eq!(h.state().views[0].find.as_ref().unwrap().matches.len(), 0, "\"page\" alone, lower case, appears nowhere"); h.state_mut().views[0].find.as_mut().unwrap().query = "PAGE".into(); h.state_mut().views[0].rerun_find(); - h.run_steps(2); + let deadline = std::time::Instant::now() + std::time::Duration::from_secs(20); + while std::time::Instant::now() < deadline && h.state().views[0].find.as_ref().unwrap().matches.len() < 5 { + h.run_steps(2); + std::thread::sleep(std::time::Duration::from_millis(5)); + } assert_eq!(h.state().views[0].find.as_ref().unwrap().matches.len(), 5); }