Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_runner: format coverage report for tap reporter #51119

Merged
merged 2 commits into from
Dec 15, 2023
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
2 changes: 1 addition & 1 deletion lib/internal/test_runner/reporter/tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ async function * tapReporter(source) {
yield `${indent(data.nesting)}# ${tapEscape(data.message)}\n`;
break;
case 'test:coverage':
yield getCoverageReport(indent(data.nesting), data.summary, '# ', '');
yield getCoverageReport(indent(data.nesting), data.summary, '# ', '', true);
break;
}
}
Expand Down
36 changes: 19 additions & 17 deletions test/parallel/test-runner-coverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@
function getTapCoverageFixtureReport() {
pulkit-30 marked this conversation as resolved.
Show resolved Hide resolved
const report = [
'# start of coverage report',
'# file | line % | branch % | funcs % | uncovered lines',
'# test/fixtures/test-runner/coverage.js | 78.65 | 38.46 | 60.00 | 12, ' +
'13, 16, 17, 18, 19, 20, 21, 22, 27, 39, 43, 44, 61, 62, 66, 67, 71, 72',
'# test/fixtures/test-runner/invalid-tap.js | 100.00 | 100.00 | 100.00 | ',
'# test/fixtures/v8-coverage/throw.js | 71.43 | 50.00 | 100.00 | 5, 6',
'# all files | 78.35 | 43.75 | 60.00 |',
'# -------------------------------------------------------------------------------------------------------------------',

Check failure on line 27 in test/parallel/test-runner-coverage.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

This line has a length of 124. Maximum allowed is 120
'# file | line % | branch % | funcs % | uncovered lines',
'# -------------------------------------------------------------------------------------------------------------------',

Check failure on line 29 in test/parallel/test-runner-coverage.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

This line has a length of 124. Maximum allowed is 120
'# test/fixtures/test-runner/coverage.js | 78.65 | 38.46 | 60.00 | 12-13 16-22 27 39 43-44 61-62 66-67 71-72',

Check failure on line 30 in test/parallel/test-runner-coverage.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

This line has a length of 123. Maximum allowed is 120
'# test/fixtures/test-runner/invalid-tap.js | 100.00 | 100.00 | 100.00 | ',
'# test/fixtures/v8-coverage/throw.js | 71.43 | 50.00 | 100.00 | 5-6',
'# -------------------------------------------------------------------------------------------------------------------',

Check failure on line 33 in test/parallel/test-runner-coverage.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

This line has a length of 124. Maximum allowed is 120
'# all files | 78.35 | 43.75 | 60.00 |',
'# -------------------------------------------------------------------------------------------------------------------',

Check failure on line 35 in test/parallel/test-runner-coverage.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

This line has a length of 124. Maximum allowed is 120
'# end of coverage report',
].join('\n');

Expand Down Expand Up @@ -88,7 +91,6 @@
const options = { env: { ...process.env, NODE_V8_COVERAGE: tmpdir.path } };
const result = spawnSync(process.execPath, args, options);
const report = getTapCoverageFixtureReport();

assert(result.stdout.toString().includes(report));
assert.strictEqual(result.stderr.toString(), '');
assert.strictEqual(result.status, 0);
Expand Down Expand Up @@ -152,16 +154,16 @@
test('coverage is combined for multiple processes', skipIfNoInspector, () => {
let report = [
'# start of coverage report',
'# file | line % | branch % | funcs % | uncovered lines',
'# common.js | 89.86 | ' +
'62.50 | 100.00 | 8, 13, 14, 18, 34, 35, 53',
'# first.test.js | 83.33 | ' +
'100.00 | 50.00 | 5, 6',
'# second.test.js | 100.00 ' +
'| 100.00 | 100.00 | ',
'# third.test.js | 100.00 | ' +
'100.00 | 100.00 | ',
'# all files | 92.11 | 72.73 | 88.89 |',
'# -------------------------------------------------------------------',
'# file | line % | branch % | funcs % | uncovered lines',
'# -------------------------------------------------------------------',
'# common.js | 89.86 | 62.50 | 100.00 | 8 13-14 18 34-35 53',
'# first.test.js | 83.33 | 100.00 | 50.00 | 5-6',
'# second.test.js | 100.00 | 100.00 | 100.00 | ',
'# third.test.js | 100.00 | 100.00 | 100.00 | ',
'# -------------------------------------------------------------------',
'# all files | 92.11 | 72.73 | 88.89 |',
'# -------------------------------------------------------------------',
'# end of coverage report',
].join('\n');

Expand Down
Loading