mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 20:29:11 +00:00
fix(coverage): error if no files found (#21615)
This commit fixes a panic in `deno coverage` command if the file to be covered doesn't produce any coverage data. Fixes https://github.com/denoland/deno/issues/21580
This commit is contained in:
parent
a44a5de430
commit
5b2caed7fd
3 changed files with 10 additions and 1 deletions
|
@ -630,3 +630,9 @@ File | Branch % | Line % |
|
||||||
",
|
",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
itest!(no_files_found {
|
||||||
|
args: "coverage doesnt_exist.js",
|
||||||
|
exit_code: 1,
|
||||||
|
output: "coverage/doesnt_exist.out",
|
||||||
|
});
|
||||||
|
|
1
cli/tests/testdata/coverage/doesnt_exist.out
vendored
Normal file
1
cli/tests/testdata/coverage/doesnt_exist.out
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
error: No coverage files found
|
|
@ -453,8 +453,10 @@ pub async fn cover_files(
|
||||||
|
|
||||||
// Use the first include path as the default output path.
|
// Use the first include path as the default output path.
|
||||||
let coverage_root = coverage_flags.files.include[0].clone();
|
let coverage_root = coverage_flags.files.include[0].clone();
|
||||||
|
|
||||||
let script_coverages = collect_coverages(coverage_flags.files)?;
|
let script_coverages = collect_coverages(coverage_flags.files)?;
|
||||||
|
if script_coverages.is_empty() {
|
||||||
|
return Err(generic_error("No coverage files found"));
|
||||||
|
}
|
||||||
let script_coverages = filter_coverages(
|
let script_coverages = filter_coverages(
|
||||||
script_coverages,
|
script_coverages,
|
||||||
coverage_flags.include,
|
coverage_flags.include,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue