Skip to content

Commit ccd4faf

Browse files
author
Aviv Keller
authored
Revert "test_runner: ignore unmapped lines for coverage"
This reverts commit 3a42085. PR-URL: #55339 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
1 parent f98d9c1 commit ccd4faf

File tree

2 files changed

+1
-53
lines changed

2 files changed

+1
-53
lines changed

lib/internal/test_runner/coverage.js

+1-27
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict';
22
const {
33
ArrayFrom,
4-
ArrayPrototypeForEach,
54
ArrayPrototypeMap,
65
ArrayPrototypePush,
76
JSONParse,
@@ -58,21 +57,12 @@ class CoverageLine {
5857
}
5958

6059
class TestCoverage {
61-
constructor(
62-
coverageDirectory,
63-
originalCoverageDirectory,
64-
workingDirectory,
65-
excludeGlobs,
66-
includeGlobs,
67-
sourceMaps,
68-
thresholds,
69-
) {
60+
constructor(coverageDirectory, originalCoverageDirectory, workingDirectory, excludeGlobs, includeGlobs, thresholds) {
7061
this.coverageDirectory = coverageDirectory;
7162
this.originalCoverageDirectory = originalCoverageDirectory;
7263
this.workingDirectory = workingDirectory;
7364
this.excludeGlobs = excludeGlobs;
7465
this.includeGlobs = includeGlobs;
75-
this.sourceMaps = sourceMaps;
7666
this.thresholds = thresholds;
7767
}
7868

@@ -376,13 +366,7 @@ class TestCoverage {
376366
this.getLines(data.sources[j], data.sourcesContent[j]);
377367
}
378368
}
379-
380369
const sourceMap = new SourceMap(data, { __proto__: null, lineLengths });
381-
const linesToCover = new SafeSet();
382-
383-
for (let i = 0; i < sourceMap[kMappings].length; i++) {
384-
linesToCover.add(sourceMap[kMappings][i][3] + 1);
385-
}
386370

387371
for (let j = 0; j < functions.length; ++j) {
388372
const { ranges, functionName, isBlockCoverage } = functions[j];
@@ -431,15 +415,6 @@ class TestCoverage {
431415
// No mappable ranges. Skip the function.
432416
continue;
433417
}
434-
435-
if (this.sourceMaps) {
436-
ArrayPrototypeForEach(this.getLines(newUrl), (mappedLine) => {
437-
if (!linesToCover.has(mappedLine.line)) {
438-
mappedLine.ignore = true;
439-
}
440-
});
441-
}
442-
443418
const newScript = newResult.get(newUrl) ?? { __proto__: null, url: newUrl, functions: [] };
444419
ArrayPrototypePush(newScript.functions, { __proto__: null, functionName, ranges: newRanges, isBlockCoverage });
445420
newResult.set(newUrl, newScript);
@@ -539,7 +514,6 @@ function setupCoverage(options) {
539514
options.cwd,
540515
options.coverageExcludeGlobs,
541516
options.coverageIncludeGlobs,
542-
options.sourceMaps,
543517
{
544518
__proto__: null,
545519
line: options.lineCoverage,

test/parallel/test-runner-coverage-source-map.js

-26
Original file line numberDiff line numberDiff line change
@@ -45,31 +45,6 @@ describe('Coverage with source maps', async () => {
4545
t.assert.strictEqual(spawned.code, 1);
4646
});
4747

48-
it('accounts only mapped lines when --enable-source-maps is provided', async (t) => {
49-
const report = generateReport([
50-
'# --------------------------------------------------------------',
51-
'# file | line % | branch % | funcs % | uncovered lines',
52-
'# --------------------------------------------------------------',
53-
'# a.test.ts | 100.00 | 100.00 | 100.00 | ', // part of a bundle
54-
'# b.test.ts | 88.89 | 100.00 | 100.00 | 1', // part of a bundle
55-
'# index.test.js | 71.43 | 66.67 | 100.00 | 6-7', // no source map
56-
'# stdin.test.ts | 100.00 | 100.00 | 100.00 | ', // Source map without original file
57-
'# --------------------------------------------------------------',
58-
'# all files | 91.67 | 87.50 | 100.00 | ',
59-
'# --------------------------------------------------------------',
60-
]);
61-
62-
const spawned = await common.spawnPromisified(process.execPath, [
63-
'--test', '--experimental-test-coverage', '--enable-source-maps', '--test-reporter', 'tap',
64-
], {
65-
cwd: fixtures.path('test-runner', 'coverage')
66-
});
67-
68-
t.assert.strictEqual(spawned.stderr, '');
69-
t.assert.ok(spawned.stdout.includes(report));
70-
t.assert.strictEqual(spawned.code, 1);
71-
});
72-
7348
await it('properly accounts for line endings in source maps', async (t) => {
7449
const report = generateReport([
7550
'# ------------------------------------------------------------------',
@@ -114,7 +89,6 @@ describe('Coverage with source maps', async () => {
11489
const spawned = await common.spawnPromisified(process.execPath, [...flags, file]);
11590

11691
const error = `The source map for '${pathToFileURL(file)}' does not exist or is corrupt`;
117-
11892
t.assert.strictEqual(spawned.stderr, '');
11993
t.assert.ok(spawned.stdout.includes(error));
12094
t.assert.strictEqual(spawned.code, 1);

0 commit comments

Comments
 (0)