mirror of
https://github.com/denoland/deno
synced 2024-08-27 03:50:16 +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
|
@ -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.
|
||||
let coverage_root = coverage_flags.files.include[0].clone();
|
||||
|
||||
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(
|
||||
script_coverages,
|
||||
coverage_flags.include,
|
||||
|
|
Loading…
Reference in a new issue