mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 20:29:11 +00:00
feat(test): support DENO_COVERAGE_DIR env var (#28291)
This PR adds support of `DENO_COVERAGE_DIR` for controlling coverage output.
This commit is contained in:
parent
a5b407c390
commit
202f5f3910
6 changed files with 43 additions and 1 deletions
|
@ -838,7 +838,7 @@ impl CliOptions {
|
||||||
.coverage_dir
|
.coverage_dir
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(ToOwned::to_owned)
|
.map(ToOwned::to_owned)
|
||||||
.or_else(|| env::var("DENO_UNSTABLE_COVERAGE_DIR").ok()),
|
.or_else(|| env::var("DENO_COVERAGE_DIR").ok()),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
18
tests/specs/coverage/set_coverage_in_env_var/__test__.jsonc
Normal file
18
tests/specs/coverage/set_coverage_in_env_var/__test__.jsonc
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"tempDir": true,
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"args": "test -A",
|
||||||
|
"output": "test.out",
|
||||||
|
"envs": {
|
||||||
|
"DENO_COVERAGE_DIR": "my_coverage_dir"
|
||||||
|
},
|
||||||
|
"exitCode": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"args": "coverage my_coverage_dir",
|
||||||
|
"output": "coverage.out",
|
||||||
|
"exitCode": 0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
--------------------------------
|
||||||
|
File | Branch % | Line % |
|
||||||
|
--------------------------------
|
||||||
|
source.ts | 100.0 | 100.0 |
|
||||||
|
--------------------------------
|
||||||
|
All files | 100.0 | 100.0 |
|
||||||
|
--------------------------------
|
3
tests/specs/coverage/set_coverage_in_env_var/source.ts
Normal file
3
tests/specs/coverage/set_coverage_in_env_var/source.ts
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
export function add(a: number, b: number): number {
|
||||||
|
return a + b;
|
||||||
|
}
|
7
tests/specs/coverage/set_coverage_in_env_var/test.out
Normal file
7
tests/specs/coverage/set_coverage_in_env_var/test.out
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
Check [WILDCARD]/test.ts
|
||||||
|
running 1 test from ./test.ts
|
||||||
|
add() ... ok ([WILDCARD])
|
||||||
|
|
||||||
|
ok | 1 passed | 0 failed ([WILDCARD])
|
||||||
|
|
||||||
|
[WILDCARD]
|
7
tests/specs/coverage/set_coverage_in_env_var/test.ts
Normal file
7
tests/specs/coverage/set_coverage_in_env_var/test.ts
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
import { add } from "./source.ts";
|
||||||
|
|
||||||
|
Deno.test("add()", () => {
|
||||||
|
if (add(1, 2) !== 3) {
|
||||||
|
throw new Error("test failed");
|
||||||
|
}
|
||||||
|
});
|
Loading…
Add table
Add a link
Reference in a new issue