diff options
author | Zheyu Zhang <zheyuzhang03@gmail.com> | 2022-02-01 00:39:39 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-31 17:39:39 +0100 |
commit | 5490cfed2000a063ef0baec500ab7d539203067c (patch) | |
tree | d121da8ad8274de65f77fbced5f452ecb1d7881a /cli/tests | |
parent | 3e566bb457663cec57602e564f73ded817e426a8 (diff) |
feat(cli): add "--no-clear-screen" flag (#13454)
This commit adds "--no-clear-screen" flag which can be used
with "--watch" flag to disable clearing of terminal screen on
each file change.
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/integration/watcher_tests.rs | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/cli/tests/integration/watcher_tests.rs b/cli/tests/integration/watcher_tests.rs index 89d4bf3f7..cdc7a2c98 100644 --- a/cli/tests/integration/watcher_tests.rs +++ b/cli/tests/integration/watcher_tests.rs @@ -997,3 +997,51 @@ fn test_watch_module_graph_error_referrer() { wait_for("Process failed", &mut stderr_lines); check_alive_then_kill(child); } + +#[test] +fn watch_with_no_clear_screen_flag() { + let t = TempDir::new().unwrap(); + let file_to_watch = t.path().join("file_to_watch.js"); + write(&file_to_watch, "export const foo = 0;").unwrap(); + + // choose deno run subcommand to test --no-clear-screen flag + let mut child = util::deno_cmd() + .current_dir(util::testdata_path()) + .arg("run") + .arg("--watch") + .arg("--no-clear-screen") + .arg("--unstable") + .arg(&file_to_watch) + .env("NO_COLOR", "1") + .stdout(std::process::Stdio::piped()) + .stderr(std::process::Stdio::piped()) + .spawn() + .unwrap(); + let (_, mut stderr_lines) = child_lines(&mut child); + + let next_line = stderr_lines.next().unwrap(); + + // no clear screen + assert!(!&next_line.contains(CLEAR_SCREEN)); + assert_contains!(&next_line, "Process started"); + assert_contains!( + stderr_lines.next().unwrap(), + "Process finished. Restarting on file change..." + ); + + // Change content of the file + write(&file_to_watch, "export const bar = 0;").unwrap(); + + let next_line = stderr_lines.next().unwrap(); + + // no clear screen + assert!(!&next_line.contains(CLEAR_SCREEN)); + + assert_contains!(&next_line, "Watcher File change detected! Restarting!"); + assert_contains!( + stderr_lines.next().unwrap(), + "Process finished. Restarting on file change..." + ); + + check_alive_then_kill(child); +} |