summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2022-04-26 14:46:49 -0400
committerGitHub <noreply@github.com>2022-04-26 14:46:49 -0400
commita1b4aa2ae60d215e38c6871fae690e34964a27d7 (patch)
treec41baf3067ca2a618bd458f1101bf9cf98506dae /cli/tests
parentf07f246ae8a158e33e81aa4ccf225cd536795f50 (diff)
fix(test): capture inherited stdout and stderr for subprocesses in test output (#14395)
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/integration/test_tests.rs6
-rw-r--r--cli/tests/testdata/test/captured_subprocess_output.out17
-rw-r--r--cli/tests/testdata/test/captured_subprocess_output.ts23
3 files changed, 46 insertions, 0 deletions
diff --git a/cli/tests/integration/test_tests.rs b/cli/tests/integration/test_tests.rs
index 0b811349a..1e8db52fd 100644
--- a/cli/tests/integration/test_tests.rs
+++ b/cli/tests/integration/test_tests.rs
@@ -302,6 +302,12 @@ itest!(no_prompt_with_denied_perms {
output: "test/no_prompt_with_denied_perms.out",
});
+itest!(captured_subprocess_output {
+ args: "test --allow-run --allow-read --unstable test/captured_subprocess_output.ts",
+ exit_code: 0,
+ output: "test/captured_subprocess_output.out",
+});
+
#[test]
fn recursive_permissions_pledge() {
let output = util::deno_cmd()
diff --git a/cli/tests/testdata/test/captured_subprocess_output.out b/cli/tests/testdata/test/captured_subprocess_output.out
new file mode 100644
index 000000000..2a40170af
--- /dev/null
+++ b/cli/tests/testdata/test/captured_subprocess_output.out
@@ -0,0 +1,17 @@
+[WILDCARD]
+running 1 test from [WILDCARD]/captured_subprocess_output.ts
+output ...
+------- output -------
+1
+2
+3
+4
+5
+6
+7
+8
+----- 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_subprocess_output.ts b/cli/tests/testdata/test/captured_subprocess_output.ts
new file mode 100644
index 000000000..277ac340e
--- /dev/null
+++ b/cli/tests/testdata/test/captured_subprocess_output.ts
@@ -0,0 +1,23 @@
+Deno.test("output", async () => {
+ const p = Deno.run({
+ cmd: [Deno.execPath(), "eval", "console.log(1); console.error(2);"],
+ });
+ await p.status();
+ await p.close();
+ Deno.spawnSync(Deno.execPath(), {
+ args: ["eval", "console.log(3); console.error(4);"],
+ stdout: "inherit",
+ stderr: "inherit",
+ });
+ await Deno.spawn(Deno.execPath(), {
+ args: ["eval", "console.log(5); console.error(6);"],
+ stdout: "inherit",
+ stderr: "inherit",
+ });
+ const c = await Deno.spawnChild(Deno.execPath(), {
+ args: ["eval", "console.log(7); console.error(8);"],
+ stdout: "inherit",
+ stderr: "inherit",
+ });
+ await c.status;
+});