Skip to content

Commit

Permalink
test_runner: ignore unmappes lines for coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
geeksilva97 committed Sep 29, 2024
1 parent e225f00 commit 5dc8328
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/internal/test_runner/coverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const {
ArrayFrom,
ArrayPrototypeMap,
ArrayPrototypePush,
ArrayPrototypeForEach,

Check failure on line 6 in lib/internal/test_runner/coverage.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Out of ASCIIbetical order - ArrayPrototypePush >= ArrayPrototypeForEach
JSONParse,
MathFloor,
MathMax,
Expand Down Expand Up @@ -365,6 +366,12 @@ class TestCoverage {
}
}
const sourceMap = new SourceMap(data, { __proto__: null, lineLengths });
const linesToCover = new Set();

Check failure on line 369 in lib/internal/test_runner/coverage.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Use `const { SafeSet } = primordials;` instead of the global

for(let mapping of sourceMap[kMappings]) {

Check failure on line 371 in lib/internal/test_runner/coverage.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Expected space(s) after "for"

Check failure on line 371 in lib/internal/test_runner/coverage.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

'mapping' is never reassigned. Use 'const' instead
const { 3: originalLine } = mapping

Check failure on line 372 in lib/internal/test_runner/coverage.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Missing semicolon
linesToCover.add(originalLine + 1);
}

for (let j = 0; j < functions.length; ++j) {
const { ranges, functionName, isBlockCoverage } = functions[j];
Expand Down Expand Up @@ -413,6 +420,13 @@ class TestCoverage {
// No mappable ranges. Skip the function.
continue;
}

ArrayPrototypeForEach(this.getLines(newUrl), (mappedLine) => {
if (!linesToCover.has(mappedLine.line)) {
mappedLine.ignore = true;
}
});

const newScript = newResult.get(newUrl) ?? { __proto__: null, url: newUrl, functions: [] };
ArrayPrototypePush(newScript.functions, { __proto__: null, functionName, ranges: newRanges, isBlockCoverage });
newResult.set(newUrl, newScript);
Expand Down

0 comments on commit 5dc8328

Please sign in to comment.