Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/watch/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
18 changes: 7 additions & 11 deletions tests/watch_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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);
Expand Down
Loading