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 | |
parent | ee2f4e745c33797ac9fd20571e77cef73ea585bf (diff) |
fix(coverage): ensure coverage is only collected in certain situations (#15467)
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/integration/coverage_tests.rs | 1 | ||||
-rw-r--r-- | cli/tests/testdata/coverage/complex_test.ts | 32 |
2 files changed, 33 insertions, 0 deletions
diff --git a/cli/tests/integration/coverage_tests.rs b/cli/tests/integration/coverage_tests.rs index 59c1a5092..251577c4b 100644 --- a/cli/tests/integration/coverage_tests.rs +++ b/cli/tests/integration/coverage_tests.rs @@ -32,6 +32,7 @@ fn run_coverage_text(test_name: &str, extension: &str) { let status = util::deno_cmd_with_deno_dir(&deno_dir) .current_dir(util::testdata_path()) .arg("test") + .arg("-A") .arg("--quiet") .arg("--unstable") .arg(format!("--coverage={}", tempdir.to_str().unwrap())) 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"); + } +}); |