Skip to content

Commit 5ef665f

Browse files
islandryuaduh95
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 84568dc commit 5ef665f

File tree

4 files changed

+42
-3
lines changed

4 files changed

+42
-3
lines changed

lib/internal/test_runner/utils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ function getCoverageReport(pad, summary, symbol, color, table) {
465465
if (color) {
466466
filePadLength += 2;
467467
}
468-
filePadLength = MathMax(filePadLength, 'file'.length);
468+
filePadLength = MathMax(filePadLength, 'all files'.length);
469469
if (filePadLength > (process.stdout.columns / 2)) {
470470
filePadLength = MathFloor(process.stdout.columns / 2);
471471
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Flags: --experimental-test-coverage --no-warnings
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`);
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

+7-2
Original file line numberDiff line numberDiff line change
@@ -297,12 +297,17 @@ const tests = [
297297
name: 'test-runner/output/coverage-width-infinity-uncovered-lines.mjs',
298298
flags: ['--test-reporter=tap'],
299299
} : false,
300+
process.features.inspector ? {
301+
name: 'test-runner/output/coverage-short-filename.mjs',
302+
flags: ['--test-reporter=tap', '--test-coverage-exclude=../output/**'],
303+
cwd: fixtures.path('test-runner/coverage-snap'),
304+
} : false,
300305
]
301306
.filter(Boolean)
302-
.map(({ flags, name, tty, transform }) => ({
307+
.map(({ flags, name, tty, transform, cwd }) => ({
303308
name,
304309
fn: common.mustCall(async () => {
305-
await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform, { tty, flags });
310+
await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform, { tty, flags, cwd });
306311
}),
307312
}));
308313

0 commit comments

Comments
 (0)