diff options
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/integration/test_tests.rs | 36 | ||||
-rw-r--r-- | cli/tests/testdata/test/captured_output.out | 19 | ||||
-rw-r--r-- | cli/tests/testdata/test/captured_output.ts | 8 | ||||
-rw-r--r-- | cli/tests/testdata/test/captured_output.worker.js | 4 |
4 files changed, 37 insertions, 30 deletions
diff --git a/cli/tests/integration/test_tests.rs b/cli/tests/integration/test_tests.rs index 328d9b494..022e40f4b 100644 --- a/cli/tests/integration/test_tests.rs +++ b/cli/tests/integration/test_tests.rs @@ -302,11 +302,37 @@ itest!(no_prompt_with_denied_perms { output: "test/no_prompt_with_denied_perms.out", }); -itest!(captured_output { - args: "test --allow-run --allow-read --unstable test/captured_output.ts", - exit_code: 0, - output: "test/captured_output.out", -}); +#[test] +fn captured_output() { + let output = util::deno_cmd() + .current_dir(util::testdata_path()) + .arg("test") + .arg("--allow-run") + .arg("--allow-read") + .arg("--unstable") + .arg("test/captured_output.ts") + .env("NO_COLOR", "1") + .stdout(std::process::Stdio::piped()) + .spawn() + .unwrap() + .wait_with_output() + .unwrap(); + + let output_start = "------- output -------"; + let output_end = "----- output end -----"; + assert!(output.status.success()); + let output_text = String::from_utf8(output.stdout).unwrap(); + let start = output_text.find(output_start).unwrap() + output_start.len(); + let end = output_text.find(output_end).unwrap(); + let output_text = output_text[start..end].trim(); + let mut lines = output_text.lines().collect::<Vec<_>>(); + // the output is racy on either stdout or stderr being flushed + // from the runtime into the rust code, so sort it... the main + // thing here to ensure is that we're capturing the output in + // this block on stdout + lines.sort_unstable(); + assert_eq!(lines.join(" "), "0 1 2 3 4 5 6 7 8 9"); +} #[test] fn recursive_permissions_pledge() { diff --git a/cli/tests/testdata/test/captured_output.out b/cli/tests/testdata/test/captured_output.out deleted file mode 100644 index 5ac367561..000000000 --- a/cli/tests/testdata/test/captured_output.out +++ /dev/null @@ -1,19 +0,0 @@ -[WILDCARD] -running 1 test from [WILDCARD]/captured_output.ts -output ... -------- output ------- -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 ------ output end ----- -ok ([WILDCARD]s) - -test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD]s) -[WILDCARD] diff --git a/cli/tests/testdata/test/captured_output.ts b/cli/tests/testdata/test/captured_output.ts index 3710c27b0..6e74ef4ad 100644 --- a/cli/tests/testdata/test/captured_output.ts +++ b/cli/tests/testdata/test/captured_output.ts @@ -1,21 +1,21 @@ Deno.test("output", async () => { const p = Deno.run({ - cmd: [Deno.execPath(), "eval", "console.log(1); console.error(2);"], + cmd: [Deno.execPath(), "eval", "console.log(0); console.error(1);"], }); await p.status(); await p.close(); Deno.spawnSync(Deno.execPath(), { - args: ["eval", "console.log(3); console.error(4);"], + args: ["eval", "console.log(2); console.error(3);"], stdout: "inherit", stderr: "inherit", }); await Deno.spawn(Deno.execPath(), { - args: ["eval", "console.log(5); console.error(6);"], + args: ["eval", "console.log(4); console.error(5);"], stdout: "inherit", stderr: "inherit", }); const c = await Deno.spawnChild(Deno.execPath(), { - args: ["eval", "console.log(7); console.error(8);"], + args: ["eval", "console.log(6); console.error(7);"], stdout: "inherit", stderr: "inherit", }); diff --git a/cli/tests/testdata/test/captured_output.worker.js b/cli/tests/testdata/test/captured_output.worker.js index b674bce56..f49f26880 100644 --- a/cli/tests/testdata/test/captured_output.worker.js +++ b/cli/tests/testdata/test/captured_output.worker.js @@ -1,6 +1,6 @@ self.onmessage = () => { - console.log(9); - console.error(10); + console.log(8); + console.error(9); self.postMessage({}); self.close(); }; |