summaryrefslogtreecommitdiff
path: root/cli/tests/integration_tests.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests/integration_tests.rs')
-rw-r--r--cli/tests/integration_tests.rs44
1 files changed, 44 insertions, 0 deletions
diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs
index e00c7a865..ec13f7380 100644
--- a/cli/tests/integration_tests.rs
+++ b/cli/tests/integration_tests.rs
@@ -982,6 +982,50 @@ fn info_with_compiled_source() {
}
#[test]
+fn run_watch() {
+ let t = TempDir::new().expect("tempdir fail");
+ let file_to_watch = t.path().join("file_to_watch.js");
+ std::fs::write(&file_to_watch, "console.log('Hello world');")
+ .expect("error writing file");
+
+ let mut child = util::deno_cmd()
+ .current_dir(util::root_path())
+ .arg("run")
+ .arg("--watch")
+ .arg("--unstable")
+ .arg(&file_to_watch)
+ .env("NO_COLOR", "1")
+ .stdout(std::process::Stdio::piped())
+ .stderr(std::process::Stdio::piped())
+ .spawn()
+ .expect("failed to spawn script");
+
+ let stdout = child.stdout.as_mut().unwrap();
+ let mut stdout_lines =
+ std::io::BufReader::new(stdout).lines().map(|r| r.unwrap());
+ let stderr = child.stderr.as_mut().unwrap();
+ let mut stderr_lines =
+ std::io::BufReader::new(stderr).lines().map(|r| r.unwrap());
+
+ assert!(stdout_lines.next().unwrap().contains("Hello world"));
+ assert!(stderr_lines.next().unwrap().contains("Process terminated"));
+
+ // TODO(lucacasonato): remove this timeout. It seems to be needed on Linux.
+ std::thread::sleep(std::time::Duration::from_secs(1));
+
+ // Change content of the file
+ std::fs::write(&file_to_watch, "console.log('Hello world2');")
+ .expect("error writing file");
+
+ assert!(stderr_lines.next().unwrap().contains("Restarting"));
+ assert!(stdout_lines.next().unwrap().contains("Hello world2"));
+ assert!(stderr_lines.next().unwrap().contains("Process terminated"));
+
+ child.kill().unwrap();
+ drop(t);
+}
+
+#[test]
fn repl_test_console_log() {
let (out, err) = util::run_and_collect_output(
true,