mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 17:34:47 -05:00
fix: --inspect flag working like --inspect-brk (#5697)
This commit is contained in:
parent
8d8a2f573f
commit
491feb859f
3 changed files with 33 additions and 1 deletions
|
@ -552,7 +552,9 @@ impl State {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn should_inspector_break_on_first_statement(&self) -> bool {
|
pub fn should_inspector_break_on_first_statement(&self) -> bool {
|
||||||
let state = self.borrow();
|
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)]
|
#[cfg(test)]
|
||||||
|
|
5
cli/tests/inspector4.js
Normal file
5
cli/tests/inspector4.js
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
console.log("hello");
|
||||||
|
|
||||||
|
setInterval(() => {
|
||||||
|
console.log("hello from interval");
|
||||||
|
}, 1000);
|
|
@ -2465,6 +2465,31 @@ async fn inspector_does_not_hang() {
|
||||||
assert!(child.wait().unwrap().success());
|
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]
|
#[test]
|
||||||
fn exec_path() {
|
fn exec_path() {
|
||||||
let output = util::deno_cmd()
|
let output = util::deno_cmd()
|
||||||
|
|
Loading…
Add table
Reference in a new issue