diff options
Diffstat (limited to 'cli/tests/integration/watcher_tests.rs')
-rw-r--r-- | cli/tests/integration/watcher_tests.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/cli/tests/integration/watcher_tests.rs b/cli/tests/integration/watcher_tests.rs index 58b703701..407a63f6c 100644 --- a/cli/tests/integration/watcher_tests.rs +++ b/cli/tests/integration/watcher_tests.rs @@ -1122,6 +1122,35 @@ fn test_watch_unload_handler_error_on_drop() { check_alive_then_kill(child); } +#[cfg(unix)] +#[test] +fn test_watch_sigint() { + use nix::sys::signal; + use nix::sys::signal::Signal; + use nix::unistd::Pid; + + let t = TempDir::new(); + let file_to_watch = t.path().join("file_to_watch.js"); + write(&file_to_watch, r#"Deno.test("foo", () => {});"#).unwrap(); + let mut child = util::deno_cmd() + .current_dir(util::testdata_path()) + .arg("test") + .arg("--watch") + .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("Test started", &mut stderr_lines); + wait_contains("ok | 1 passed | 0 failed", &mut stdout_lines); + wait_contains("Test finished", &mut stderr_lines); + signal::kill(Pid::from_raw(child.id() as i32), Signal::SIGINT).unwrap(); + let exit_status = child.wait().unwrap(); + assert_eq!(exit_status.code(), Some(130)); +} + // Regression test for https://github.com/denoland/deno/issues/15465. #[test] fn run_watch_reload_once() { |