diff --git a/src/watch/event_loop.rs b/src/watch/event_loop.rs index ecde381..628a3c3 100644 --- a/src/watch/event_loop.rs +++ b/src/watch/event_loop.rs @@ -1062,14 +1062,16 @@ 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={dispatch_count}", + dispatch_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() + "expected the mid-build source edit to survive cooldown; got dispatches: {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);