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 <[email protected]>
This commit is contained in:
Brandon ThomasandClaude Opus 5.5 committed 2026-10-10 08:14:40 -04:00
1 parent 1c33e6f851
commit 4280f83bb0
1 file changed
+9 -2
+9 -2
View File
@@ -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);
}