Skip to content

Commit 10a2ddf

Browse files
committed
test_runner: remove unnecessary padding
1 parent 694ee5e commit 10a2ddf

9 files changed

+101
-98
lines changed

lib/internal/test_runner/utils.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ function buildFileTree(summary) {
412412
let longestFile = 0;
413413

414414
ArrayPrototypeForEach(summary.files, (file) => {
415+
let longestPart = 0;
415416
const parts = relative(summary.workingDirectory, file.path).split('/');
416417
let current = tree;
417418
ArrayPrototypeForEach(parts, (part, index) => {
@@ -424,9 +425,11 @@ function buildFileTree(summary) {
424425
current.file = file;
425426
current.finalPath = parts;
426427
}
428+
// Keep track of the longest part for padding
429+
longestPart = MathMax(longestPart, part.length);
427430
});
428431
treeDepth = MathMax(treeDepth, parts.length);
429-
longestFile = MathMax(longestFile, ...parts.map((part) => part.length));
432+
longestFile = longestPart;
430433
});
431434

432435
return { __proto__: null, tree, treeDepth, longestFile };
@@ -448,7 +451,7 @@ function getCoverageReport(pad, summary, symbol, color, table) {
448451
// Calculate expected column sizes based on the tree
449452
// Every level of the tree adds 2 to the column size + the longest file name
450453
filePadLength = table && longestFile;
451-
filePadLength += 2 * treeDepth;
454+
filePadLength += 1 * treeDepth;
452455
// Get the maximum length of the file path or 'file'
453456
filePadLength = MathMax(filePadLength, 'file'.length);
454457
const fileWidth = filePadLength + 2;

test/fixtures/test-runner/output/coverage-width-100-uncovered-lines.snapshot

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ ok 1 - Coverage Print Fixed Width 100
1515
# duration_ms *
1616
# start of coverage report
1717
# --------------------------------------------------------------------------------------------------
18-
# file | line % | branch % | funcs % | uncovered lines
18+
# file | line % | branch % | funcs % | uncovered lines
1919
# --------------------------------------------------------------------------------------------------
20-
# test | | | |
21-
# fixtures | | | |
22-
# test-runner | | | |
23-
# coverage-snap | | | |
24-
# a.js | 55.77 | 100.00 | 0.00 | 5-7 9-11 13-15 …
25-
# b.js | 45.45 | 100.00 | 0.00 | 5-7 9-11
26-
# many-uncovered-lines.js | 50.99 | 42.86 | 1.92 | 5-7 9-11 13-15 …
27-
# output | | | |
28-
# coverage-width-100-uncovered-lines.mjs | 100.00 | 100.00 | 100.00 |
20+
# test | | | |
21+
# fixtures | | | |
22+
# test-runner | | | |
23+
# coverage-snap | | | |
24+
# a.js | 55.77 | 100.00 | 0.00 | 5-7 9-11 13-15 17-19
25+
# b.js | 45.45 | 100.00 | 0.00 | 5-7 9-11
26+
# many-uncovered-lines.js | 50.99 | 42.86 | 1.92 | 5-7 9-11 13-15 17-19
27+
# output | | | |
28+
# coverage-width-100-uncovered-lines.mjs | 100.00 | 100.00 | 100.00 |
2929
# --------------------------------------------------------------------------------------------------
30-
# all files | 52.80 | 60.00 | 1.61 |
30+
# all files | 52.80 | 60.00 | 1.61 |
3131
# --------------------------------------------------------------------------------------------------
3232
# end of coverage report

test/fixtures/test-runner/output/coverage-width-100.snapshot

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ ok 1 - Coverage Print Fixed Width 100
1515
# duration_ms *
1616
# start of coverage report
1717
# --------------------------------------------------------------------------------------------------
18-
# file | line % | branch % | funcs % | uncovered lines
18+
# file | line % | branch % | funcs % | uncovered lines
1919
# --------------------------------------------------------------------------------------------------
20-
# test | | | |
21-
# fixtures | | | |
22-
# test-runner | | | |
23-
# coverage-snap | | | |
24-
# a.js | 55.77 | 100.00 | 0.00 | 5-7 9-11 13-15 17-19 29-30 40-4
25-
# b.js | 45.45 | 100.00 | 0.00 | 5-7 9-11
26-
# output | | | |
27-
# coverage-width-100.mjs | 100.00 | 100.00 | 100.00 |
20+
# test | | | |
21+
# fixtures | | | |
22+
# test-runner | | | |
23+
# coverage-snap | | | |
24+
# a.js | 55.77 | 100.00 | 0.00 | 5-7 9-11 13-15 17-19 29-30 40-42 45-
25+
# b.js | 45.45 | 100.00 | 0.00 | 5-7 9-11
26+
# output | | | |
27+
# coverage-width-100.mjs | 100.00 | 100.00 | 100.00 |
2828
# --------------------------------------------------------------------------------------------------
29-
# all files | 60.81 | 100.00 | 0.00 |
29+
# all files | 60.81 | 100.00 | 0.00 |
3030
# --------------------------------------------------------------------------------------------------
3131
# end of coverage report

test/fixtures/test-runner/output/coverage-width-150-uncovered-lines.snapshot

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ ok 1 - Coverage Print Fixed Width 150
1515
# duration_ms *
1616
# start of coverage report
1717
# ----------------------------------------------------------------------------------------------------------------------------------------------------
18-
# file | line % | branch % | funcs % | uncovered lines
18+
# file | line % | branch % | funcs % | uncovered lines
1919
# ----------------------------------------------------------------------------------------------------------------------------------------------------
20-
# test | | | |
21-
# fixtures | | | |
22-
# test-runner | | | |
23-
# coverage-snap | | | |
24-
# a.js | 55.77 | 100.00 | 0.00 | 5-7 9-11 13-15 17-19 29-30 40-42 45-47 50-52
25-
# b.js | 45.45 | 100.00 | 0.00 | 5-7 9-11
26-
# many-uncovered-lines.js | 50.99 | 42.86 | 1.92 | 5-7 9-11 13-15 17-19 29-30 40-42 45-47 50-52 55-57 59-61 63-65 67…
27-
# output | | | |
28-
# coverage-width-150-uncovered-lines.mjs | 100.00 | 100.00 | 100.00 |
20+
# test | | | |
21+
# fixtures | | | |
22+
# test-runner | | | |
23+
# coverage-snap | | | |
24+
# a.js | 55.77 | 100.00 | 0.00 | 5-7 9-11 13-15 17-19 29-30 40-42 45-47 50-52
25+
# b.js | 45.45 | 100.00 | 0.00 | 5-7 9-11
26+
# many-uncovered-lines.js | 50.99 | 42.86 | 1.92 | 5-7 9-11 13-15 17-19 29-30 40-42 45-47 50-52 55-57 59-61 63-65 67-69 9
27+
# output | | | |
28+
# coverage-width-150-uncovered-lines.mjs | 100.00 | 100.00 | 100.00 |
2929
# ----------------------------------------------------------------------------------------------------------------------------------------------------
30-
# all files | 52.80 | 60.00 | 1.61 |
30+
# all files | 52.80 | 60.00 | 1.61 |
3131
# ----------------------------------------------------------------------------------------------------------------------------------------------------
3232
# end of coverage report

test/fixtures/test-runner/output/coverage-width-150.snapshot

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@ ok 1 - Coverage Print Fixed Width 150
1414
# todo 0
1515
# duration_ms *
1616
# start of coverage report
17-
# --------------------------------------------------------------------------------------------------------------
18-
# file | line % | branch % | funcs % | uncovered lines
19-
# --------------------------------------------------------------------------------------------------------------
20-
# test | | | |
21-
# fixtures | | | |
22-
# test-runner | | | |
23-
# coverage-snap | | | |
24-
# a.js | 55.77 | 100.00 | 0.00 | 5-7 9-11 13-15 17-19 29-30 40-42 45-47 50-52
25-
# b.js | 45.45 | 100.00 | 0.00 | 5-7 9-11
26-
# output | | | |
27-
# coverage-width-150.mjs | 100.00 | 100.00 | 100.00 |
28-
# --------------------------------------------------------------------------------------------------------------
29-
# all files | 60.81 | 100.00 | 0.00 |
30-
# --------------------------------------------------------------------------------------------------------------
17+
# ---------------------------------------------------------------------------------------------------------
18+
# file | line % | branch % | funcs % | uncovered lines
19+
# ---------------------------------------------------------------------------------------------------------
20+
# test | | | |
21+
# fixtures | | | |
22+
# test-runner | | | |
23+
# coverage-snap | | | |
24+
# a.js | 55.77 | 100.00 | 0.00 | 5-7 9-11 13-15 17-19 29-30 40-42 45-47 50-52
25+
# b.js | 45.45 | 100.00 | 0.00 | 5-7 9-11
26+
# output | | | |
27+
# coverage-width-150.mjs | 100.00 | 100.00 | 100.00 |
28+
# ---------------------------------------------------------------------------------------------------------
29+
# all files | 60.81 | 100.00 | 0.00 |
30+
# ---------------------------------------------------------------------------------------------------------
3131
# end of coverage report

test/fixtures/test-runner/output/coverage-width-80-uncovered-lines.snapshot

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ ok 1 - Coverage Print Fixed Width 100
1515
# duration_ms *
1616
# start of coverage report
1717
# --------------------------------------------------------------------------------------------------
18-
# file | line % | branch % | funcs % | uncovered lines
18+
# file | line % | branch % | funcs % | uncovered lines
1919
# --------------------------------------------------------------------------------------------------
20-
# test | | | |
21-
# fixtures | | | |
22-
# test-runner | | | |
23-
# coverage-snap | | | |
24-
# a.js | 55.77 | 100.00 | 0.00 | 5-7 9-11 13-15 1
25-
# b.js | 45.45 | 100.00 | 0.00 | 5-7 9-11
26-
# many-uncovered-lines.js | 50.99 | 42.86 | 1.92 | 5-7 9-11 13-15 1
27-
# output | | | |
28-
# coverage-width-80-uncovered-lines.mjs | 100.00 | 100.00 | 100.00 |
20+
# test | | | |
21+
# fixtures | | | |
22+
# test-runner | | | |
23+
# coverage-snap | | | |
24+
# a.js | 55.77 | 100.00 | 0.00 | 5-7 9-11 13-15 17-19
25+
# b.js | 45.45 | 100.00 | 0.00 | 5-7 9-11
26+
# many-uncovered-lines.js | 50.99 | 42.86 | 1.92 | 5-7 9-11 13-15 17-19
27+
# output | | | |
28+
# coverage-width-80-uncovered-lines.mjs | 100.00 | 100.00 | 100.00 |
2929
# --------------------------------------------------------------------------------------------------
30-
# all files | 52.80 | 60.00 | 1.61 |
30+
# all files | 52.80 | 60.00 | 1.61 |
3131
# --------------------------------------------------------------------------------------------------
3232
# end of coverage report

test/fixtures/test-runner/output/coverage-width-80.snapshot

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ ok 1 - Coverage Print Fixed Width 80
1515
# duration_ms *
1616
# start of coverage report
1717
# ------------------------------------------------------------------------------
18-
# file | line % | branch % | funcs % | uncovered li…
18+
# file | line % | branch % | funcs % | uncovered lines
1919
# ------------------------------------------------------------------------------
20-
# test | | | |
21-
# fixtures | | | |
22-
# test-runner | | | |
23-
# coverage-snap | | | |
24-
# a.js | 55.77 | 100.00 | 0.00 | 5-7 9-11 13-…
25-
# b.js | 45.45 | 100.00 | 0.00 | 5-7 9-11
26-
# output | | | |
27-
# coverage-width-80.mjs | 100.00 | 100.00 | 100.00 |
20+
# test | | | |
21+
# fixtures | | | |
22+
# test-runner | | | |
23+
# coverage-snap | | | |
24+
# a.js | 55.77 | 100.00 | 0.00 | 5-7 9-11 13-15 17
25+
# b.js | 45.45 | 100.00 | 0.00 | 5-7 9-11
26+
# output | | | |
27+
# coverage-width-80.mjs | 100.00 | 100.00 | 100.00 |
2828
# ------------------------------------------------------------------------------
29-
# all files | 60.81 | 100.00 | 0.00 |
29+
# all files | 60.81 | 100.00 | 0.00 |
3030
# ------------------------------------------------------------------------------
3131
# end of coverage report

0 commit comments

Comments
 (0)