Pace the unwatch regression test so it is not flaky (AI-assisted)

A burst of 200 operations within milliseconds sometimes made macOS coalesce events into a rescan,
which notify 4 does not deliver, failing the test about 4 times in 10 even with the fix. With a
5 ms pause per iteration the fixed code passed 20 of 20 runs; the unfixed code still loses about a
third of the creations (60-67 of 100).
This commit is contained in:
Noah Peeters 2026-10-19 17:14:05 +02:00
parent 75c19ddb6a
commit 10bc251d7f

View file

@ -173,6 +173,9 @@ mod test {
fs::remove_file(&removed).unwrap(); fs::remove_file(&removed).unwrap();
let _ = backend.unwatch(&removed); let _ = backend.unwatch(&removed);
fs::write(new.join(format!("{i}.txt")), "").unwrap(); fs::write(new.join(format!("{i}.txt")), "").unwrap();
// Paced so the OS does not coalesce the burst into a rescan, which notify 4 drops on
// its own; this test is about the events unwatch loses.
thread::sleep(Duration::from_millis(5));
} }
let mut created = HashSet::new(); let mut created = HashSet::new();