From a1b4aa2ae60d215e38c6871fae690e34964a27d7 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Tue, 26 Apr 2022 14:46:49 -0400 Subject: fix(test): capture inherited stdout and stderr for subprocesses in test output (#14395) --- .../testdata/test/captured_subprocess_output.out | 17 ++++++++++++++++ .../testdata/test/captured_subprocess_output.ts | 23 ++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 cli/tests/testdata/test/captured_subprocess_output.out create mode 100644 cli/tests/testdata/test/captured_subprocess_output.ts (limited to 'cli/tests/testdata') 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; +}); -- cgit v1.2.3