mirror of
https://github.com/denoland/deno.git
synced 2025-08-31 07:47:46 +00:00
fix(coverage): ignore files from npm registry (#18457)
Fixes https://github.com/denoland/deno/issues/17664 and part of https://github.com/denoland/deno/issues/18454 by excluding files belonging to npm modules by default in the coverage output.
This commit is contained in:
parent
30ee846588
commit
206c593519
6 changed files with 65 additions and 0 deletions
|
@ -588,6 +588,7 @@ fn filter_coverages(
|
|||
coverages: Vec<ScriptCoverage>,
|
||||
include: Vec<String>,
|
||||
exclude: Vec<String>,
|
||||
npm_root_dir: &str,
|
||||
) -> Vec<ScriptCoverage> {
|
||||
let include: Vec<Regex> =
|
||||
include.iter().map(|e| Regex::new(e).unwrap()).collect();
|
||||
|
@ -599,6 +600,7 @@ fn filter_coverages(
|
|||
.into_iter()
|
||||
.filter(|e| {
|
||||
let is_internal = e.url.starts_with("ext:")
|
||||
|| e.url.starts_with(npm_root_dir)
|
||||
|| e.url.ends_with("__anonymous__")
|
||||
|| e.url.ends_with("$deno$test.js")
|
||||
|| e.url.ends_with(".snap");
|
||||
|
@ -620,12 +622,14 @@ pub async fn cover_files(
|
|||
}
|
||||
|
||||
let ps = ProcState::build(flags).await?;
|
||||
let root_dir_url = ps.npm_resolver.root_dir_url();
|
||||
|
||||
let script_coverages = collect_coverages(coverage_flags.files)?;
|
||||
let script_coverages = filter_coverages(
|
||||
script_coverages,
|
||||
coverage_flags.include,
|
||||
coverage_flags.exclude,
|
||||
root_dir_url.as_str(),
|
||||
);
|
||||
|
||||
let proc_coverages: Vec<_> = script_coverages
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue