diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2023-02-03 19:15:16 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-03 20:15:16 +0100 |
commit | a635c9700c0b99c3ad128c21727fdcfb23bad72f (patch) | |
tree | b31e457547346bd979df45579ca62186ee6027f2 /cli/tests/integration/watcher_tests.rs | |
parent | b16a958c4f01a1d27d14a6a1d8785c54449a5087 (diff) |
refactor: reland "preserve ProcState::file_fetcher between restarts" (#17636)
Just some watcher init step that I thought would be "cloned over" but
needs to be done again on reset.
Diffstat (limited to 'cli/tests/integration/watcher_tests.rs')
-rw-r--r-- | cli/tests/integration/watcher_tests.rs | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/cli/tests/integration/watcher_tests.rs b/cli/tests/integration/watcher_tests.rs index 113067122..5ba16cd5e 100644 --- a/cli/tests/integration/watcher_tests.rs +++ b/cli/tests/integration/watcher_tests.rs @@ -635,9 +635,14 @@ fn run_watch_external_watch_files() { // Change content of the external file write(&external_file_to_watch, "Hello world2").unwrap(); + wait_contains("Restarting", &mut stderr_lines); + wait_contains("Process finished", &mut stderr_lines); + // Again (https://github.com/denoland/deno/issues/17584) + write(&external_file_to_watch, "Hello world3").unwrap(); wait_contains("Restarting", &mut stderr_lines); wait_contains("Process finished", &mut stderr_lines); + check_alive_then_kill(child); } @@ -1086,6 +1091,44 @@ fn test_watch_unload_handler_error_on_drop() { 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(); @@ -1147,11 +1190,11 @@ fn run_watch_dynamic_imports() { &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, |