summaryrefslogtreecommitdiff
path: root/cli/tests/watcher_tests.rs
diff options
context:
space:
mode:
authorNayeem Rahman <nayeemrmn99@gmail.com>2023-01-10 15:28:10 +0000
committerGitHub <noreply@github.com>2023-01-10 16:28:10 +0100
commit71ea4ef2746d7d75623a821d4832d3531a8e1654 (patch)
tree7d5d9676c5de9b32edcc2aee9a94394e4de2a19f /cli/tests/watcher_tests.rs
parent0329bc69dabbcc4d57ff9d34d695ffd4ddb1de4f (diff)
fix(watch): preserve `ProcState::file_fetcher` between restarts (#15466)
This commit changes "ProcState" to store "file_fetcher" field in an "Arc", allowing it to be preserved between restarts and thus keeping the state alive between the restarts. File watchers for "deno test" and "deno bench" now reset "ProcState" between restarts.
Diffstat (limited to 'cli/tests/watcher_tests.rs')
-rw-r--r--cli/tests/watcher_tests.rs40
1 files changed, 39 insertions, 1 deletions
diff --git a/cli/tests/watcher_tests.rs b/cli/tests/watcher_tests.rs
index 0b9749e48..a300f3953 100644
--- a/cli/tests/watcher_tests.rs
+++ b/cli/tests/watcher_tests.rs
@@ -1098,6 +1098,44 @@ mod watcher {
check_alive_then_kill(child);
}
+ // Regression test for https://github.com/denoland/deno/issues/15465.
+ #[test]
+ fn run_watch_reload_once() {
+ let _g = util::http_server();
+ let t = TempDir::new();
+ let file_to_watch = t.path().join("file_to_watch.js");
+ let file_content = r#"
+ import { time } from "http://localhost:4545/dynamic_module.ts";
+ console.log(time);
+ "#;
+ write(&file_to_watch, file_content).unwrap();
+
+ let mut child = util::deno_cmd()
+ .current_dir(util::testdata_path())
+ .arg("run")
+ .arg("--watch")
+ .arg("--reload")
+ .arg(&file_to_watch)
+ .env("NO_COLOR", "1")
+ .stdout(std::process::Stdio::piped())
+ .stderr(std::process::Stdio::piped())
+ .spawn()
+ .unwrap();
+ let (mut stdout_lines, mut stderr_lines) = child_lines(&mut child);
+
+ wait_contains("finished", &mut stderr_lines);
+ let first_output = stdout_lines.next().unwrap();
+
+ write(&file_to_watch, file_content).unwrap();
+ // The remote dynamic module should not have been reloaded again.
+
+ wait_contains("finished", &mut stderr_lines);
+ let second_output = stdout_lines.next().unwrap();
+ assert_eq!(second_output, first_output);
+
+ check_alive_then_kill(child);
+ }
+
#[test]
fn run_watch_dynamic_imports() {
let t = TempDir::new();
@@ -1159,11 +1197,11 @@ mod watcher {
&mut stdout_lines,
);
- wait_contains("finished", &mut stderr_lines);
wait_for(
|m| m.contains("Watching paths") && m.contains("imported2.js"),
&mut stderr_lines,
);
+ wait_contains("finished", &mut stderr_lines);
write(
&file_to_watch3,