Skip to content

Commit 85e4ba5

Browse files
committed
test_runner: fixing style issues
1 parent 9dba88a commit 85e4ba5

3 files changed

Lines changed: 23 additions & 11 deletions

File tree

lib/internal/test_runner/coverage.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const {
1313
StringPrototypeIncludes,
1414
StringPrototypeLocaleCompare,
1515
StringPrototypeStartsWith,
16-
MathMax
16+
MathMax,
1717
} = primordials;
1818
const {
1919
copyFileSync,
@@ -170,8 +170,9 @@ class TestCoverage {
170170

171171
if (isBlockCoverage) {
172172
ArrayPrototypePush(branchReports, {
173+
__proto__: null,
173174
line: range.lines[0].line,
174-
count: range.count
175+
count: range.count,
175176
});
176177

177178
if (range.count !== 0 ||
@@ -187,9 +188,10 @@ class TestCoverage {
187188
const range = ranges[0];
188189

189190
ArrayPrototypePush(functionReports, {
191+
__proto__: null,
190192
name: functions[j].functionName,
191193
count: MathMax(...ArrayPrototypeMap(ranges, r => r.count)),
192-
line: range.lines[0].line
194+
line: range.lines[0].line,
193195
});
194196

195197
if (range.count !== 0 || range.ignoredLines === range.lines.length) {
@@ -209,10 +211,18 @@ class TestCoverage {
209211
if (line.covered || line.ignore) {
210212
coveredCnt++;
211213
if (!line.ignore) {
212-
ArrayPrototypePush(lineReports, { line: line.line, count: line.count })
214+
ArrayPrototypePush(lineReports, {
215+
__proto__: null,
216+
line: line.line,
217+
count: line.count,
218+
})
213219
}
214220
} else {
215-
ArrayPrototypePush(lineReports, { line: line.line, count: 0 });
221+
ArrayPrototypePush(lineReports, {
222+
__proto__: null,
223+
line: line.line,
224+
count: 0,
225+
});
216226
}
217227
}
218228

lib/internal/test_runner/utils.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
const {
33
ArrayPrototypeJoin,
44
ArrayPrototypeMap,
5+
ArrayPrototypeFlatMap,
56
ArrayPrototypePush,
67
ArrayPrototypeReduce,
78
ObjectGetOwnPropertyDescriptor,
@@ -34,6 +35,7 @@ const {
3435
kIsNodeError,
3536
} = require('internal/errors');
3637
const { compose } = require('stream');
38+
const console = require('console');
3739

3840
const coverageColors = {
3941
__proto__: null,
@@ -298,12 +300,7 @@ function formatLinesToRanges(values) {
298300
}
299301

300302
function getUncoveredLines(lines) {
301-
return ArrayPrototypeReduce(lines, (acc, line) => {
302-
if (line.count === 0) {
303-
ArrayPrototypePush(acc, line.line);
304-
}
305-
return acc;
306-
}, []);
303+
return ArrayPrototypeFlatMap(lines, (line) => line.count === 0 ? line.line : []);
307304
}
308305

309306
function formatUncoveredLines(lines, table) {

test/parallel/test-runner-coverage.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ test('test tap coverage reporter', skipIfNoInspector, async (t) => {
8989
const result = spawnSync(process.execPath, args, options);
9090
const report = getTapCoverageFixtureReport();
9191

92+
console.log("=======")
93+
console.log("RESULT\n", result.stdout.toString())
94+
console.log("EXPECTED\n", report)
95+
console.log("=======")
96+
9297
assert(result.stdout.toString().includes(report));
9398
assert.strictEqual(result.stderr.toString(), '');
9499
assert.strictEqual(result.status, 0);

0 commit comments

Comments
 (0)