mirror of
https://github.com/denoland/deno.git
synced 2025-10-03 07:34:36 +00:00
fix(coverage): ensure coverage is only collected in certain situations (#15467)
This commit is contained in:
parent
ee2f4e745c
commit
8eed24cd3d
7 changed files with 60 additions and 12 deletions
32
cli/tests/testdata/coverage/complex_test.ts
vendored
32
cli/tests/testdata/coverage/complex_test.ts
vendored
|
@ -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");
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue