From 10bc251d7f68fd3e8bdf903e1714cc20c3201dfe Mon Sep 17 00:00:00 2001 From: Noah Peeters Date: Mon, 19 Oct 2026 17:14:05 +0200 Subject: [PATCH] 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). --- crates/memofs/src/std_backend.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/memofs/src/std_backend.rs b/crates/memofs/src/std_backend.rs index 637d65cd..f70bedcf 100644 --- a/crates/memofs/src/std_backend.rs +++ b/crates/memofs/src/std_backend.rs @@ -173,6 +173,9 @@ mod test { fs::remove_file(&removed).unwrap(); let _ = backend.unwatch(&removed); 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();