0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 17:34:47 -05:00

fix(coverage): do not generate script coverage with empty url (#24007)

closes #24004
This commit is contained in:
Yoshiya Hinosawa 2024-05-28 23:01:32 +09:00 committed by GitHub
parent 9aa593cd5d
commit 8b5089e41f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

View file

@ -68,12 +68,14 @@ impl crate::worker::CoverageCollector for CoverageCollector {
let script_coverages = self.take_precise_coverage().await?.result; let script_coverages = self.take_precise_coverage().await?.result;
for script_coverage in script_coverages { for script_coverage in script_coverages {
// Filter out internal and http/https JS files from being included in coverage reports // Filter out internal and http/https JS files and eval'd scripts
// from being included in coverage reports
if script_coverage.url.starts_with("ext:") if script_coverage.url.starts_with("ext:")
|| script_coverage.url.starts_with("[ext:") || script_coverage.url.starts_with("[ext:")
|| script_coverage.url.starts_with("http:") || script_coverage.url.starts_with("http:")
|| script_coverage.url.starts_with("https:") || script_coverage.url.starts_with("https:")
|| script_coverage.url.starts_with("node:") || script_coverage.url.starts_with("node:")
|| script_coverage.url.is_empty()
{ {
continue; continue;
} }

View file

@ -20,3 +20,7 @@ Deno.test("qux", () => {
Deno.test("quux", () => { Deno.test("quux", () => {
quux(false); quux(false);
}); });
// Function constructor or eval function generates a new script source internally.
// This call ensures that the coverage data for the eval script source is not generated.
eval("console.log(1)");