Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test_runner: fixing style issues
  • Loading branch information
philnash committed Aug 25, 2023
commit 85e4ba5ab1d6ec2c8f5d80aa44217fa769ba0a86
20 changes: 15 additions & 5 deletions lib/internal/test_runner/coverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const {
StringPrototypeIncludes,
StringPrototypeLocaleCompare,
StringPrototypeStartsWith,
MathMax
MathMax,
} = primordials;
const {
copyFileSync,
Expand Down Expand Up @@ -170,8 +170,9 @@ class TestCoverage {

if (isBlockCoverage) {
ArrayPrototypePush(branchReports, {
__proto__: null,
line: range.lines[0].line,
count: range.count
count: range.count,
});

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

ArrayPrototypePush(functionReports, {
__proto__: null,
name: functions[j].functionName,
count: MathMax(...ArrayPrototypeMap(ranges, r => r.count)),
line: range.lines[0].line
line: range.lines[0].line,
});

if (range.count !== 0 || range.ignoredLines === range.lines.length) {
Expand All @@ -209,10 +211,18 @@ class TestCoverage {
if (line.covered || line.ignore) {
coveredCnt++;
if (!line.ignore) {
ArrayPrototypePush(lineReports, { line: line.line, count: line.count })
ArrayPrototypePush(lineReports, {
__proto__: null,
line: line.line,
count: line.count,
})
}
} else {
ArrayPrototypePush(lineReports, { line: line.line, count: 0 });
ArrayPrototypePush(lineReports, {
__proto__: null,
line: line.line,
count: 0,
});
}
}

Expand Down
9 changes: 3 additions & 6 deletions lib/internal/test_runner/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
const {
ArrayPrototypeJoin,
ArrayPrototypeMap,
ArrayPrototypeFlatMap,
ArrayPrototypePush,
ArrayPrototypeReduce,
ObjectGetOwnPropertyDescriptor,
Expand Down Expand Up @@ -34,6 +35,7 @@ const {
kIsNodeError,
} = require('internal/errors');
const { compose } = require('stream');
const console = require('console');

const coverageColors = {
__proto__: null,
Expand Down Expand Up @@ -298,12 +300,7 @@ function formatLinesToRanges(values) {
}

function getUncoveredLines(lines) {
return ArrayPrototypeReduce(lines, (acc, line) => {
if (line.count === 0) {
ArrayPrototypePush(acc, line.line);
}
return acc;
}, []);
return ArrayPrototypeFlatMap(lines, (line) => line.count === 0 ? line.line : []);
}

function formatUncoveredLines(lines, table) {
Expand Down
5 changes: 5 additions & 0 deletions test/parallel/test-runner-coverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ test('test tap coverage reporter', skipIfNoInspector, async (t) => {
const result = spawnSync(process.execPath, args, options);
const report = getTapCoverageFixtureReport();

console.log("=======")
console.log("RESULT\n", result.stdout.toString())
console.log("EXPECTED\n", report)
console.log("=======")

assert(result.stdout.toString().includes(report));
assert.strictEqual(result.stderr.toString(), '');
assert.strictEqual(result.status, 0);
Expand Down