mirror of
https://github.com/denoland/deno.git
synced 2024-11-22 04:51:22 +00:00
fix(coverage): Error if no files are included in the report (#22952)
Fixes #22941. In that case, the only file with coverage was the `test.ts` file. The coverage reporter filters out test files before compiling its report, so after filtering we were left with an empty set of files. Later on it's assumed that there is at least 1 file to be reported on, and we panic. Instead of panicking, just issue an error after filtering.
This commit is contained in:
parent
92576fdcfd
commit
ab67b4c645
@ -485,6 +485,9 @@ pub async fn cover_files(
|
|||||||
coverage_flags.exclude,
|
coverage_flags.exclude,
|
||||||
npm_resolver.as_ref(),
|
npm_resolver.as_ref(),
|
||||||
);
|
);
|
||||||
|
if script_coverages.is_empty() {
|
||||||
|
return Err(generic_error("No covered files included in the report"));
|
||||||
|
}
|
||||||
|
|
||||||
let proc_coverages: Vec<_> = script_coverages
|
let proc_coverages: Vec<_> = script_coverages
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
15
tests/specs/coverage/no_files_after_filter/__test__.jsonc
Normal file
15
tests/specs/coverage/no_files_after_filter/__test__.jsonc
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"tempDir": true,
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"args": "test --coverage test.ts",
|
||||||
|
"output": "test_coverage.out",
|
||||||
|
"exitCode": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"args": "coverage ./coverage",
|
||||||
|
"output": "no_files_in_report.out",
|
||||||
|
"exitCode": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
error: No covered files included in the report
|
1
tests/specs/coverage/no_files_after_filter/test.ts
Normal file
1
tests/specs/coverage/no_files_after_filter/test.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
Deno.test("test", () => {});
|
@ -0,0 +1,6 @@
|
|||||||
|
Check [WILDCARD]/test.ts
|
||||||
|
running 1 test from ./test.ts
|
||||||
|
test ... ok ([WILDCARD])
|
||||||
|
|
||||||
|
ok | 1 passed | 0 failed ([WILDCARD])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user