From bfce376c685694569be2cbf0716dd58f898c111e Mon Sep 17 00:00:00 2001 From: Yusuke Tanaka Date: Wed, 28 Oct 2020 20:41:18 +0900 Subject: refactor(watch): create single watcher for whole process (#8083) This commit rewrites file watcher used with --watch flag. Instead of creating new watcher after each restart, only a single watcher is created for whole process. Additionally debouncing mechanism has been added to prevent infinite restart loops if multiple files were changed in quick succession. Co-authored-by: bartossh --- cli/tests/integration_tests.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'cli/tests') diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index f7b4c345a..0bba369fe 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -1210,6 +1210,9 @@ fn run_watch() { std::fs::write(&file_to_watch, "console.log('Hello world2');") .expect("error writing file"); + // Events from the file watcher is "debounced", so we need to wait for the next execution to start + std::thread::sleep(std::time::Duration::from_secs(1)); + assert!(stderr_lines.next().unwrap().contains("Restarting")); assert!(stdout_lines.next().unwrap().contains("Hello world2")); assert!(stderr_lines.next().unwrap().contains("Process terminated")); -- cgit v1.2.3