diff options
Diffstat (limited to 'cli/tests/watcher_tests.rs')
-rw-r--r-- | cli/tests/watcher_tests.rs | 40 |
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, |