Skip to content

Commit 7416a7f

Browse files
islandryuRafaelGSS
authored andcommitted
test_runner: match minimum file column to 'all files'
PR-URL: #57848 Reviewed-By: Pietro Marchini <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Jake Yuesong Li <[email protected]>
1 parent 77dee41 commit 7416a7f

File tree

4 files changed

+42
-3
lines changed

4 files changed

+42
-3
lines changed

lib/internal/test_runner/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ function getCoverageReport(pad, summary, symbol, color, table) {
468468
if (color) {
469469
filePadLength += 2;
470470
}
471-
filePadLength = MathMax(filePadLength, 'file'.length);
471+
filePadLength = MathMax(filePadLength, 'all files'.length);
472472
if (filePadLength > (process.stdout.columns / 2)) {
473473
filePadLength = MathFloor(process.stdout.columns / 2);
474474
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Flags: --experimental-test-coverage
2+
// here we can't import common module as the coverage will be different based on the system
3+
// Unused imports are here in order to populate the coverage report
4+
// eslint-disable-next-line no-unused-vars
5+
import * as a from '../coverage-snap/a.js';
6+
7+
import { test } from 'node:test';
8+
9+
test(`Coverage Print Short Filename`);
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
TAP version 13
2+
# Subtest: Coverage Print Short Filename
3+
ok 1 - Coverage Print Short Filename
4+
---
5+
duration_ms: *
6+
type: 'test'
7+
...
8+
1..1
9+
# tests 1
10+
# suites 0
11+
# pass 1
12+
# fail 0
13+
# cancelled 0
14+
# skipped 0
15+
# todo 0
16+
# duration_ms *
17+
# start of coverage report
18+
# ---------------------------------------------------------------------------------------
19+
# file | line % | branch % | funcs % | uncovered lines
20+
# ---------------------------------------------------------------------------------------
21+
# a.js | 55.77 | 100.00 | 0.00 | 5-7 9-11 13-15 17-19 29-30 40-42 45-47 50-52
22+
# ---------------------------------------------------------------------------------------
23+
# all files | 55.77 | 100.00 | 0.00 |
24+
# ---------------------------------------------------------------------------------------
25+
# end of coverage report

test/parallel/test-runner-output.mjs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,12 +308,17 @@ const tests = [
308308
name: 'test-runner/output/coverage-width-infinity-uncovered-lines.mjs',
309309
flags: ['--test-reporter=tap', '--test-coverage-exclude=!test/**'],
310310
} : false,
311+
process.features.inspector ? {
312+
name: 'test-runner/output/coverage-short-filename.mjs',
313+
flags: ['--test-reporter=tap', '--test-coverage-exclude=../output/**'],
314+
cwd: fixtures.path('test-runner/coverage-snap'),
315+
} : false,
311316
]
312317
.filter(Boolean)
313-
.map(({ flags, name, tty, transform }) => ({
318+
.map(({ flags, name, tty, transform, cwd }) => ({
314319
name,
315320
fn: common.mustCall(async () => {
316-
await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform, { tty, flags });
321+
await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform, { tty, flags, cwd });
317322
}),
318323
}));
319324

0 commit comments

Comments
 (0)