Repository: nodejs/node
Pull request: test_runner: match minimum file column to 'all files'



Fixed a problem that all files are omitted when the file name displayed in coverage is too short.
```
ℹ tests 1
ℹ suites 0
ℹ pass 1
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 3.993167
ℹ start of coverage report
ℹ ------------------------------------------------------------------------------------
ℹ file   | line % | branch % | funcs % | uncovered lines
ℹ ------------------------------------------------------------------------------------
ℹ a.js   |  55.77 |   100.00 |    0.00 | 5-7 9-11 13-15 17-19 29-30 40-42 45-47 50-52
ℹ ------------------------------------------------------------------------------------
ℹ …files |  55.77 |   100.00 |    0.00 | 
ℹ ------------------------------------------------------------------------------------
ℹ end of coverage report
```


<!--
Before submitting a pull request, please read:

- the CONTRIBUTING guide at https://github.com/nodejs/node/blob/HEAD/CONTRIBUTING.md
- the commit message formatting guidelines at
  https://github.com/nodejs/node/blob/HEAD/doc/contributing/pull-requests.md#commit-message-guidelines

For code changes:
1. Include tests for any bug fixes or new features.
2. Update documentation if relevant.
3. Ensure that `make -j4 test` (UNIX), or `vcbuild test` (Windows) passes.

If you believe this PR should be highlighted in the Node.js CHANGELOG
please add the `notable-change` label.

Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.
-->


Changed files:
filename: lib/internal/test_runner/utils.js
patch: @@ -468,7 +468,7 @@ function getCoverageReport(pad, summary, symbol, color, table) {
     if (color) {
       filePadLength += 2;
     }
-    filePadLength = MathMax(filePadLength, 'file'.length);
+    filePadLength = MathMax(filePadLength, 'all files'.length);
     if (filePadLength > (process.stdout.columns / 2)) {
       filePadLength = MathFloor(process.stdout.columns / 2);
     }

filename: test/fixtures/test-runner/output/coverage-short-filename.mjs
patch: @@ -0,0 +1,9 @@
+// Flags: --experimental-test-coverage
+// here we can't import common module as the coverage will be different based on the system
+// Unused imports are here in order to populate the coverage report
+// eslint-disable-next-line no-unused-vars
+import * as a from '../coverage-snap/a.js';
+
+import { test } from 'node:test';
+
+test(`Coverage Print Short Filename`);

filename: test/fixtures/test-runner/output/coverage-short-filename.snapshot
patch: @@ -0,0 +1,25 @@
+TAP version 13
+# Subtest: Coverage Print Short Filename
+ok 1 - Coverage Print Short Filename
+  ---
+  duration_ms: *
+  type: 'test'
+  ...
+1..1
+# tests 1
+# suites 0
+# pass 1
+# fail 0
+# cancelled 0
+# skipped 0
+# todo 0
+# duration_ms *
+# start of coverage report
+# ---------------------------------------------------------------------------------------
+# file      | line % | branch % | funcs % | uncovered lines
+# ---------------------------------------------------------------------------------------
+# a.js      |  55.77 |   100.00 |    0.00 | 5-7 9-11 13-15 17-19 29-30 40-42 45-47 50-52
+# ---------------------------------------------------------------------------------------
+# all files |  55.77 |   100.00 |    0.00 | 
+# ---------------------------------------------------------------------------------------
+# end of coverage report

filename: test/parallel/test-runner-output.mjs
patch: @@ -308,12 +308,17 @@ const tests = [
     name: 'test-runner/output/coverage-width-infinity-uncovered-lines.mjs',
     flags: ['--test-reporter=tap', '--test-coverage-exclude=!test/**'],
   } : false,
+  process.features.inspector ? {
+    name: 'test-runner/output/coverage-short-filename.mjs',
+    flags: ['--test-reporter=tap', '--test-coverage-exclude=../output/**'],
+    cwd: fixtures.path('test-runner/coverage-snap'),
+  } : false,
 ]
 .filter(Boolean)
-.map(({ flags, name, tty, transform }) => ({
+.map(({ flags, name, tty, transform, cwd }) => ({
   name,
   fn: common.mustCall(async () => {
-    await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform, { tty, flags });
+    await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform, { tty, flags, cwd });
   }),
 }));