mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 02:48:24 +00:00
fix(coverage): exclude scripts with invalid URLs from raw coverage output (#28210)
Fixes https://github.com/denoland/deno/issues/28206. Basically if you execute a script with `node:vm`, this produces a "script" with the file name `evalmachine.<anonymous>`, which ends up producing coverage like ```json { "scriptId": "319", "url": "evalmachine.<anonymous>", "functions": [ { "functionName": "", "ranges": [{ "startOffset": 0, "endOffset": 18, "count": 1 }], "isBlockCoverage": true } ] } ``` We assume that the `url` field here (the specifier of the script) is a valid URL, and so we error out when processing that coverage. There are two potential fixes: either don't write the coverage files for those scripts, or ignore the errors when we process the data. I went with the former here.
This commit is contained in:
parent
b20f98ccf7
commit
e5de22b0b5
6 changed files with 39 additions and 5 deletions
|
@ -74,14 +74,15 @@ impl crate::worker::CoverageCollector for CoverageCollector {
|
|||
|
||||
let script_coverages = self.take_precise_coverage().await?.result;
|
||||
for script_coverage in script_coverages {
|
||||
// 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:")
|
||||
// Filter out internal and http/https JS files, eval'd scripts,
|
||||
// and scripts with invalid urls from being included in coverage reports
|
||||
if script_coverage.url.is_empty()
|
||||
|| script_coverage.url.starts_with("ext:")
|
||||
|| script_coverage.url.starts_with("[ext:")
|
||||
|| script_coverage.url.starts_with("http:")
|
||||
|| script_coverage.url.starts_with("https:")
|
||||
|| script_coverage.url.starts_with("node:")
|
||||
|| script_coverage.url.is_empty()
|
||||
|| Url::parse(&script_coverage.url).is_err()
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue