diff options
Diffstat (limited to 'cli/tests/integration/inspector_tests.rs')
-rw-r--r-- | cli/tests/integration/inspector_tests.rs | 151 |
1 files changed, 68 insertions, 83 deletions
diff --git a/cli/tests/integration/inspector_tests.rs b/cli/tests/integration/inspector_tests.rs index e593c3b29..36d469196 100644 --- a/cli/tests/integration/inspector_tests.rs +++ b/cli/tests/integration/inspector_tests.rs @@ -18,13 +18,12 @@ use hyper::Response; use std::io::BufRead; use std::time::Duration; use test_util as util; -use test_util::TempDir; use tokio::net::TcpStream; use tokio::time::timeout; use url::Url; use util::assert_starts_with; -use util::http_server; use util::DenoChild; +use util::TestContextBuilder; struct SpawnExecutor; @@ -292,7 +291,7 @@ async fn inspector_connect() { .arg("run") .arg(inspect_flag_with_unique_port("--inspect")) .arg(script) - .stderr(std::process::Stdio::piped()) + .stderr_piped() .spawn() .unwrap(); @@ -314,8 +313,7 @@ async fn inspector_break_on_first_line() { .arg("run") .arg(inspect_flag_with_unique_port("--inspect-brk")) .arg(script) - .stdout(std::process::Stdio::piped()) - .stderr(std::process::Stdio::piped()) + .piped_output() .spawn() .unwrap(); @@ -398,8 +396,7 @@ async fn inspector_pause() { .arg("run") .arg(inspect_flag_with_unique_port("--inspect")) .arg(script) - .stdout(std::process::Stdio::piped()) - .stderr(std::process::Stdio::piped()) + .piped_output() .spawn() .unwrap(); @@ -439,7 +436,7 @@ async fn inspector_port_collision() { .arg("run") .arg(&inspect_flag) .arg(script.clone()) - .stderr(std::process::Stdio::piped()) + .stderr_piped() .spawn() .unwrap(); @@ -453,7 +450,7 @@ async fn inspector_port_collision() { .arg("run") .arg(&inspect_flag) .arg(script) - .stderr(std::process::Stdio::piped()) + .stderr_piped() .spawn() .unwrap(); @@ -478,8 +475,7 @@ async fn inspector_does_not_hang() { .arg(inspect_flag_with_unique_port("--inspect-brk")) .env("NO_COLOR", "1") .arg(script) - .stdout(std::process::Stdio::piped()) - .stderr(std::process::Stdio::piped()) + .piped_output() .spawn() .unwrap(); @@ -569,8 +565,7 @@ async fn inspector_without_brk_runs_code() { .arg("run") .arg(inspect_flag_with_unique_port("--inspect")) .arg(script) - .stdout(std::process::Stdio::piped()) - .stderr(std::process::Stdio::piped()) + .piped_output() .spawn() .unwrap(); @@ -598,8 +593,7 @@ async fn inspector_runtime_evaluate_does_not_crash() { .arg("--allow-read") .arg(inspect_flag_with_unique_port("--inspect")) .stdin(std::process::Stdio::piped()) - .stdout(std::process::Stdio::piped()) - .stderr(std::process::Stdio::piped()) + .piped_output() .spawn() .unwrap(); @@ -707,7 +701,7 @@ async fn inspector_json() { .arg("run") .arg(inspect_flag_with_unique_port("--inspect")) .arg(script) - .stderr(std::process::Stdio::piped()) + .stderr_piped() .spawn() .unwrap(); @@ -756,7 +750,7 @@ async fn inspector_json_list() { .arg("run") .arg(inspect_flag_with_unique_port("--inspect")) .arg(script) - .stderr(std::process::Stdio::piped()) + .stderr_piped() .spawn() .unwrap(); @@ -787,7 +781,7 @@ async fn inspector_connect_non_ws() { .arg("run") .arg(inspect_flag_with_unique_port("--inspect")) .arg(script) - .stderr(std::process::Stdio::piped()) + .stderr_piped() .spawn() .unwrap(); @@ -813,8 +807,7 @@ async fn inspector_break_on_first_line_in_test() { .arg(inspect_flag_with_unique_port("--inspect-brk")) .arg(script) .env("NO_COLOR", "1") - .stdout(std::process::Stdio::piped()) - .stderr(std::process::Stdio::piped()) + .piped_output() .spawn() .unwrap(); @@ -890,8 +883,7 @@ async fn inspector_with_ts_files() { .arg("--check") .arg(inspect_flag_with_unique_port("--inspect-brk")) .arg(script) - .stdout(std::process::Stdio::piped()) - .stderr(std::process::Stdio::piped()) + .piped_output() .spawn() .unwrap(); @@ -1009,8 +1001,7 @@ async fn inspector_memory() { .arg("run") .arg(inspect_flag_with_unique_port("--inspect-brk")) .arg(script) - .stdout(std::process::Stdio::piped()) - .stderr(std::process::Stdio::piped()) + .piped_output() .spawn() .unwrap(); @@ -1110,8 +1101,7 @@ async fn inspector_profile() { .arg("run") .arg(inspect_flag_with_unique_port("--inspect-brk")) .arg(script) - .stdout(std::process::Stdio::piped()) - .stderr(std::process::Stdio::piped()) + .piped_output() .spawn() .unwrap(); @@ -1188,22 +1178,20 @@ async fn inspector_profile() { #[ignore] #[tokio::test] async fn inspector_break_on_first_line_npm_esm() { - let _server = http_server(); - - let child = util::deno_cmd() - .arg("run") - .arg("--quiet") - .arg(inspect_flag_with_unique_port("--inspect-brk")) - .arg("npm:@denotest/bin/cli-esm") - .arg("this") - .arg("is") - .arg("a") - .arg("test") - .envs(util::env_vars_for_npm_tests()) - .stdout(std::process::Stdio::piped()) - .stderr(std::process::Stdio::piped()) - .spawn() - .unwrap(); + let context = TestContextBuilder::for_npm().build(); + let child = context + .new_command() + .args_vec([ + "run", + "--quiet", + &inspect_flag_with_unique_port("--inspect-brk"), + "npm:@denotest/bin/cli-esm", + "this", + "is", + "a", + "test", + ]) + .spawn_with_piped_output(); let mut tester = InspectorTester::create(child, ignore_script_parsed).await; @@ -1258,21 +1246,20 @@ async fn inspector_break_on_first_line_npm_esm() { #[ignore] #[tokio::test] async fn inspector_break_on_first_line_npm_cjs() { - let _server = http_server(); - let child = util::deno_cmd() - .arg("run") - .arg("--quiet") - .arg(inspect_flag_with_unique_port("--inspect-brk")) - .arg("npm:@denotest/bin/cli-cjs") - .arg("this") - .arg("is") - .arg("a") - .arg("test") - .envs(util::env_vars_for_npm_tests()) - .stdout(std::process::Stdio::piped()) - .stderr(std::process::Stdio::piped()) - .spawn() - .unwrap(); + let context = TestContextBuilder::for_npm().build(); + let child = context + .new_command() + .args_vec([ + "run", + "--quiet", + &inspect_flag_with_unique_port("--inspect-brk"), + "npm:@denotest/bin/cli-cjs", + "this", + "is", + "a", + "test", + ]) + .spawn_with_piped_output(); let mut tester = InspectorTester::create(child, ignore_script_parsed).await; @@ -1328,19 +1315,17 @@ async fn inspector_break_on_first_line_npm_cjs() { #[tokio::test] async fn inspector_error_with_npm_import() { let script = util::testdata_path().join("inspector/error_with_npm_import.js"); - let _server = http_server(); - - let child = util::deno_cmd() - .arg("run") - .arg("--quiet") - .arg("-A") - .arg(inspect_flag_with_unique_port("--inspect-brk")) - .arg(script) - .envs(util::env_vars_for_npm_tests()) - .stdout(std::process::Stdio::piped()) - .stderr(std::process::Stdio::piped()) - .spawn() - .unwrap(); + let context = TestContextBuilder::for_npm().build(); + let child = context + .new_command() + .args_vec([ + "run", + "--quiet", + "-A", + &inspect_flag_with_unique_port("--inspect-brk"), + &script.to_string_lossy(), + ]) + .spawn_with_piped_output(); let mut tester = InspectorTester::create(child, ignore_script_parsed).await; @@ -1392,19 +1377,19 @@ async fn inspector_error_with_npm_import() { #[tokio::test] async fn inspector_wait() { let script = util::testdata_path().join("inspector/inspect_wait.js"); - let temp_dir = TempDir::new(); - - let child = util::deno_cmd() - .current_dir(temp_dir.path()) - .arg("run") - .arg("--quiet") - .arg("-A") - .arg(inspect_flag_with_unique_port("--inspect-wait")) - .arg(script) - .stdout(std::process::Stdio::piped()) - .stderr(std::process::Stdio::piped()) - .spawn() - .unwrap(); + let test_context = TestContextBuilder::new().use_temp_cwd().build(); + let temp_dir = test_context.temp_dir(); + + let child = test_context + .new_command() + .args_vec([ + "run", + "--quiet", + "-A", + &inspect_flag_with_unique_port("--inspect-wait"), + &script.to_string_lossy(), + ]) + .spawn_with_piped_output(); tokio::time::sleep(tokio::time::Duration::from_millis(300)).await; assert!(!temp_dir.path().join("hello.txt").exists()); |