From 2c05a08d4c48273021583d409f7b1d5e43f687ba Mon Sep 17 00:00:00 2001 From: calvin-archastro Date: Thu, 13 Aug 2026 21:06:23 -0700 Subject: [PATCH 1/2] test(watch): synchronize filesystem event assertions --- src/watch/event_loop.rs | 13 ++++++++----- tests/watch_tests.rs | 18 +++++++----------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/watch/event_loop.rs b/src/watch/event_loop.rs index ecde381..586509d 100644 --- a/src/watch/event_loop.rs +++ b/src/watch/event_loop.rs @@ -1062,14 +1062,17 @@ mod tests { std::thread::sleep(Duration::from_millis(50)); send_modify(&tx, "/repo/services/api/src/main.ts"); - // Wait long enough for the queued edit to dispatch after the first - // build returns. - std::thread::sleep(Duration::from_millis(450)); + assert!( + wait_until(|| dispatches.count() >= 2, Duration::from_secs(3)), + "dispatch #2 never fired. got count={}", + dispatches.count() + ); + let snapshot = dispatches.snapshot(); assert_eq!( - dispatches.count(), + snapshot.len(), 2, "expected the mid-build source edit to survive cooldown; got dispatches: {:?}", - dispatches.snapshot() + snapshot ); stop_loop(tx, shutdown, handle); diff --git a/tests/watch_tests.rs b/tests/watch_tests.rs index a2aa314..807a709 100644 --- a/tests/watch_tests.rs +++ b/tests/watch_tests.rs @@ -325,12 +325,6 @@ fn watch_ignores_node_modules_changes() { setup_workspace(&tmp); write(&tmp, "libs/core/package.json", &nodejs_package("core")); write(&tmp, "libs/core/src/index.ts", "export const x = 1;\n"); - write( - &tmp, - "libs/core/node_modules/foo/index.js", - "module.exports = 1;\n", - ); - let mut cmd = Command::new(aster_bin()); cmd.current_dir(tmp.path()) .arg("watch") @@ -343,11 +337,13 @@ fn watch_ignores_node_modules_changes() { assert!(wait_for_line(&rx, "watching", Duration::from_secs(5)).is_some()); drain_startup_events(&rx); - fs::write( - tmp.path().join("libs/core/node_modules/foo/index.js"), - "module.exports = 2;\n", - ) - .unwrap(); + // Model a dependency install creating node_modules after the watcher has + // started. The entire creation must remain ignored. + write( + &tmp, + "libs/core/node_modules/foo/index.js", + "module.exports = 1;\n", + ); let observed = assert_no_line_containing(&rx, "change:", Duration::from_secs(2)); kill_child(&mut child); From d6155eac6655e8cc91497a2df6588a5b6ea2cd86 Mon Sep 17 00:00:00 2001 From: calvin-archastro Date: Thu, 13 Aug 2026 21:15:59 -0700 Subject: [PATCH 2/2] test(watch): keep assertions MSRV-compatible --- src/watch/event_loop.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/watch/event_loop.rs b/src/watch/event_loop.rs index 586509d..628a3c3 100644 --- a/src/watch/event_loop.rs +++ b/src/watch/event_loop.rs @@ -1064,15 +1064,14 @@ mod tests { assert!( wait_until(|| dispatches.count() >= 2, Duration::from_secs(3)), - "dispatch #2 never fired. got count={}", - dispatches.count() + "dispatch #2 never fired. got count={dispatch_count}", + dispatch_count = dispatches.count() ); let snapshot = dispatches.snapshot(); assert_eq!( snapshot.len(), 2, - "expected the mid-build source edit to survive cooldown; got dispatches: {:?}", - snapshot + "expected the mid-build source edit to survive cooldown; got dispatches: {snapshot:?}" ); stop_loop(tx, shutdown, handle);