diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2022-08-12 15:21:17 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-12 15:21:17 -0400 |
commit | 8eed24cd3d9cea5179c65e43d23fbf6cf4d873ca (patch) | |
tree | 3047d60a9f8e972a601de011460dee151ad4c558 /cli/tests/testdata/coverage/complex_test.ts | |
parent | ee2f4e745c33797ac9fd20571e77cef73ea585bf (diff) |
fix(coverage): ensure coverage is only collected in certain situations (#15467)
Diffstat (limited to 'cli/tests/testdata/coverage/complex_test.ts')
-rw-r--r-- | cli/tests/testdata/coverage/complex_test.ts | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/cli/tests/testdata/coverage/complex_test.ts b/cli/tests/testdata/coverage/complex_test.ts index fda948bc3..1202289cb 100644 --- a/cli/tests/testdata/coverage/complex_test.ts +++ b/cli/tests/testdata/coverage/complex_test.ts @@ -3,3 +3,35 @@ import { complex } from "./complex.ts"; Deno.test("complex", function () { complex("foo", "bar", "baz"); }); + +Deno.test("sub process with stdin", async () => { + // ensure launching deno run with stdin doesn't affect coverage + const code = "console.log('5')"; + const p = await Deno.run({ + cmd: [Deno.execPath(), "run", "-"], + stdin: "piped", + stdout: "piped", + }); + const encoder = new TextEncoder(); + await p.stdin.write(encoder.encode(code)); + await p.stdin.close(); + const output = new TextDecoder().decode(await p.output()); + p.close(); + if (output.trim() !== "5") { + throw new Error("Failed"); + } +}); + +Deno.test("sub process with deno eval", async () => { + // ensure launching deno eval doesn't affect coverage + const code = "console.log('5')"; + const p = await Deno.run({ + cmd: [Deno.execPath(), "eval", code], + stdout: "piped", + }); + const output = new TextDecoder().decode(await p.output()); + p.close(); + if (output.trim() !== "5") { + throw new Error("Failed"); + } +}); |