diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2020-05-21 20:34:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-21 20:34:25 +0200 |
commit | 491feb859f30f56bc25d6afc730a1c709a0bb807 (patch) | |
tree | a5a51943d1654515d88412dafe0c459fcbd6c483 | |
parent | 8d8a2f573f32e0b2680eb114739902c5953f7b99 (diff) |
fix: --inspect flag working like --inspect-brk (#5697)
-rw-r--r-- | cli/state.rs | 4 | ||||
-rw-r--r-- | cli/tests/inspector4.js | 5 | ||||
-rw-r--r-- | cli/tests/integration_tests.rs | 25 |
3 files changed, 33 insertions, 1 deletions
diff --git a/cli/state.rs b/cli/state.rs index 4306cf102..46fbdfd0b 100644 --- a/cli/state.rs +++ b/cli/state.rs @@ -552,7 +552,9 @@ impl State { #[inline] pub fn should_inspector_break_on_first_statement(&self) -> bool { let state = self.borrow(); - state.inspector.is_some() && state.is_main + state.inspector.is_some() + && state.is_main + && state.global_state.flags.inspect_brk.is_some() } #[cfg(test)] diff --git a/cli/tests/inspector4.js b/cli/tests/inspector4.js new file mode 100644 index 000000000..1bf419650 --- /dev/null +++ b/cli/tests/inspector4.js @@ -0,0 +1,5 @@ +console.log("hello"); + +setInterval(() => { + console.log("hello from interval"); +}, 1000); diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index cec081ea6..5419d3270 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -2465,6 +2465,31 @@ async fn inspector_does_not_hang() { assert!(child.wait().unwrap().success()); } +#[tokio::test] +async fn inspector_without_brk_runs_code() { + let script = util::tests_path().join("inspector4.js"); + let mut child = util::deno_cmd() + .arg("run") + // Warning: each inspector test should be on its own port to avoid + // conflicting with another inspector test. + .arg("--inspect=127.0.0.1:9233") + .arg(script) + .stdout(std::process::Stdio::piped()) + .stderr(std::process::Stdio::piped()) + .spawn() + .unwrap(); + extract_ws_url_from_stderr(child.stderr.as_mut().unwrap()); + + // Check that inspector actually runs code without waiting for inspector + // connection + let mut stdout = std::io::BufReader::new(child.stdout.as_mut().unwrap()); + let mut stdout_first_line = String::from(""); + let _ = stdout.read_line(&mut stdout_first_line).unwrap(); + assert_eq!(stdout_first_line, "hello\n"); + + child.kill().unwrap(); +} + #[test] fn exec_path() { let output = util::deno_cmd() |