mirror of
https://github.com/denoland/deno.git
synced 2025-08-03 02:22:40 +00:00
fix(cli): panic with deno coverage
(#23353)
This PR directly addresses the issue raised in #23282 where Deno panics if `deno coverage` is called with `--include` regex that returns no matches. I've opted not to change the return value of `collect_summary` for simplicity and return an empty `HashMap` instead
This commit is contained in:
parent
88529f0b47
commit
329a8ae0c0
2 changed files with 60 additions and 1 deletions
|
@ -52,7 +52,12 @@ pub trait CoverageReporter {
|
|||
file_reports: &'a Vec<(CoverageReport, String)>,
|
||||
) -> CoverageSummary {
|
||||
let urls = file_reports.iter().map(|rep| &rep.0.url).collect();
|
||||
let root = util::find_root(urls).unwrap().to_file_path().unwrap();
|
||||
let root = match util::find_root(urls)
|
||||
.and_then(|root_path| root_path.to_file_path().ok())
|
||||
{
|
||||
Some(path) => path,
|
||||
None => return HashMap::new(),
|
||||
};
|
||||
// summary by file or directory
|
||||
// tuple of (line hit, line miss, branch hit, branch miss, parent)
|
||||
let mut summary = HashMap::new();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue