diff --git a/lib/internal/test_runner/utils.js b/lib/internal/test_runner/utils.js index 60aac50684f98a..5033b735455510 100644 --- a/lib/internal/test_runner/utils.js +++ b/lib/internal/test_runner/utils.js @@ -412,6 +412,7 @@ function buildFileTree(summary) { let longestFile = 0; ArrayPrototypeForEach(summary.files, (file) => { + let longestPart = 0; const parts = relative(summary.workingDirectory, file.path).split('/'); let current = tree; ArrayPrototypeForEach(parts, (part, index) => { @@ -424,9 +425,11 @@ function buildFileTree(summary) { current.file = file; current.finalPath = parts; } + // Keep track of the longest part for padding + longestPart = MathMax(longestPart, part.length); }); treeDepth = MathMax(treeDepth, parts.length); - longestFile = MathMax(longestFile, ...parts.map((part) => part.length)); + longestFile = longestPart; }); return { __proto__: null, tree, treeDepth, longestFile }; @@ -448,7 +451,7 @@ function getCoverageReport(pad, summary, symbol, color, table) { // Calculate expected column sizes based on the tree // Every level of the tree adds 2 to the column size + the longest file name filePadLength = table && longestFile; - filePadLength += 2 * treeDepth; + filePadLength += 1 * treeDepth; // Get the maximum length of the file path or 'file' filePadLength = MathMax(filePadLength, 'file'.length); const fileWidth = filePadLength + 2; diff --git a/test/fixtures/test-runner/output/coverage-width-100-uncovered-lines.snapshot b/test/fixtures/test-runner/output/coverage-width-100-uncovered-lines.snapshot index bb1f8873ccaa0d..7733753c1a65e4 100644 --- a/test/fixtures/test-runner/output/coverage-width-100-uncovered-lines.snapshot +++ b/test/fixtures/test-runner/output/coverage-width-100-uncovered-lines.snapshot @@ -15,18 +15,18 @@ ok 1 - Coverage Print Fixed Width 100 # duration_ms * # start of coverage report # -------------------------------------------------------------------------------------------------- -# file | line % | branch % | funcs % | uncovered lines +# file | line % | branch % | funcs % | uncovered lines # -------------------------------------------------------------------------------------------------- -# test | | | | -# fixtures | | | | -# test-runner | | | | -# coverage-snap | | | | -# a.js | 55.77 | 100.00 | 0.00 | 5-7 9-11 13-15 … -# b.js | 45.45 | 100.00 | 0.00 | 5-7 9-11 -# many-uncovered-lines.js | 50.99 | 42.86 | 1.92 | 5-7 9-11 13-15 … -# output | | | | -# coverage-width-100-uncovered-lines.mjs | 100.00 | 100.00 | 100.00 | +# test | | | | +# fixtures | | | | +# test-runner | | | | +# coverage-snap | | | | +# a.js | 55.77 | 100.00 | 0.00 | 5-7 9-11 13-15 17-19… +# b.js | 45.45 | 100.00 | 0.00 | 5-7 9-11 +# many-uncovered-lines.js | 50.99 | 42.86 | 1.92 | 5-7 9-11 13-15 17-19… +# output | | | | +# coverage-width-100-uncovered-lines.mjs | 100.00 | 100.00 | 100.00 | # -------------------------------------------------------------------------------------------------- -# all files | 52.80 | 60.00 | 1.61 | +# all files | 52.80 | 60.00 | 1.61 | # -------------------------------------------------------------------------------------------------- # end of coverage report diff --git a/test/fixtures/test-runner/output/coverage-width-100.snapshot b/test/fixtures/test-runner/output/coverage-width-100.snapshot index 5222aa0fa2f29a..3fa486d8341aec 100644 --- a/test/fixtures/test-runner/output/coverage-width-100.snapshot +++ b/test/fixtures/test-runner/output/coverage-width-100.snapshot @@ -15,17 +15,17 @@ ok 1 - Coverage Print Fixed Width 100 # duration_ms * # start of coverage report # -------------------------------------------------------------------------------------------------- -# file | line % | branch % | funcs % | uncovered lines +# file | line % | branch % | funcs % | uncovered lines # -------------------------------------------------------------------------------------------------- -# test | | | | -# fixtures | | | | -# test-runner | | | | -# coverage-snap | | | | -# a.js | 55.77 | 100.00 | 0.00 | 5-7 9-11 13-15 17-19 29-30 40-4… -# b.js | 45.45 | 100.00 | 0.00 | 5-7 9-11 -# output | | | | -# coverage-width-100.mjs | 100.00 | 100.00 | 100.00 | +# test | | | | +# fixtures | | | | +# test-runner | | | | +# coverage-snap | | | | +# a.js | 55.77 | 100.00 | 0.00 | 5-7 9-11 13-15 17-19 29-30 40-42 45-… +# b.js | 45.45 | 100.00 | 0.00 | 5-7 9-11 +# output | | | | +# coverage-width-100.mjs | 100.00 | 100.00 | 100.00 | # -------------------------------------------------------------------------------------------------- -# all files | 60.81 | 100.00 | 0.00 | +# all files | 60.81 | 100.00 | 0.00 | # -------------------------------------------------------------------------------------------------- # end of coverage report diff --git a/test/fixtures/test-runner/output/coverage-width-150-uncovered-lines.snapshot b/test/fixtures/test-runner/output/coverage-width-150-uncovered-lines.snapshot index feba10159bf827..e19b29c89afa0a 100644 --- a/test/fixtures/test-runner/output/coverage-width-150-uncovered-lines.snapshot +++ b/test/fixtures/test-runner/output/coverage-width-150-uncovered-lines.snapshot @@ -15,18 +15,18 @@ ok 1 - Coverage Print Fixed Width 150 # duration_ms * # start of coverage report # ---------------------------------------------------------------------------------------------------------------------------------------------------- -# file | line % | branch % | funcs % | uncovered lines +# file | line % | branch % | funcs % | uncovered lines # ---------------------------------------------------------------------------------------------------------------------------------------------------- -# test | | | | -# fixtures | | | | -# test-runner | | | | -# coverage-snap | | | | -# a.js | 55.77 | 100.00 | 0.00 | 5-7 9-11 13-15 17-19 29-30 40-42 45-47 50-52 -# b.js | 45.45 | 100.00 | 0.00 | 5-7 9-11 -# 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… -# output | | | | -# coverage-width-150-uncovered-lines.mjs | 100.00 | 100.00 | 100.00 | +# test | | | | +# fixtures | | | | +# test-runner | | | | +# coverage-snap | | | | +# a.js | 55.77 | 100.00 | 0.00 | 5-7 9-11 13-15 17-19 29-30 40-42 45-47 50-52 +# b.js | 45.45 | 100.00 | 0.00 | 5-7 9-11 +# 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… +# output | | | | +# coverage-width-150-uncovered-lines.mjs | 100.00 | 100.00 | 100.00 | # ---------------------------------------------------------------------------------------------------------------------------------------------------- -# all files | 52.80 | 60.00 | 1.61 | +# all files | 52.80 | 60.00 | 1.61 | # ---------------------------------------------------------------------------------------------------------------------------------------------------- # end of coverage report diff --git a/test/fixtures/test-runner/output/coverage-width-150.snapshot b/test/fixtures/test-runner/output/coverage-width-150.snapshot index 3d3172d4461a0a..1829324e69b24e 100644 --- a/test/fixtures/test-runner/output/coverage-width-150.snapshot +++ b/test/fixtures/test-runner/output/coverage-width-150.snapshot @@ -14,18 +14,18 @@ ok 1 - Coverage Print Fixed Width 150 # todo 0 # duration_ms * # start of coverage report -# -------------------------------------------------------------------------------------------------------------- -# file | line % | branch % | funcs % | uncovered lines -# -------------------------------------------------------------------------------------------------------------- -# test | | | | -# fixtures | | | | -# test-runner | | | | -# coverage-snap | | | | -# a.js | 55.77 | 100.00 | 0.00 | 5-7 9-11 13-15 17-19 29-30 40-42 45-47 50-52 -# b.js | 45.45 | 100.00 | 0.00 | 5-7 9-11 -# output | | | | -# coverage-width-150.mjs | 100.00 | 100.00 | 100.00 | -# -------------------------------------------------------------------------------------------------------------- -# all files | 60.81 | 100.00 | 0.00 | -# -------------------------------------------------------------------------------------------------------------- +# --------------------------------------------------------------------------------------------------------- +# file | line % | branch % | funcs % | uncovered lines +# --------------------------------------------------------------------------------------------------------- +# test | | | | +# fixtures | | | | +# test-runner | | | | +# coverage-snap | | | | +# a.js | 55.77 | 100.00 | 0.00 | 5-7 9-11 13-15 17-19 29-30 40-42 45-47 50-52 +# b.js | 45.45 | 100.00 | 0.00 | 5-7 9-11 +# output | | | | +# coverage-width-150.mjs | 100.00 | 100.00 | 100.00 | +# --------------------------------------------------------------------------------------------------------- +# all files | 60.81 | 100.00 | 0.00 | +# --------------------------------------------------------------------------------------------------------- # end of coverage report diff --git a/test/fixtures/test-runner/output/coverage-width-80-uncovered-lines.snapshot b/test/fixtures/test-runner/output/coverage-width-80-uncovered-lines.snapshot index 88db587a0ecc4c..365ef2c85d7cf0 100644 --- a/test/fixtures/test-runner/output/coverage-width-80-uncovered-lines.snapshot +++ b/test/fixtures/test-runner/output/coverage-width-80-uncovered-lines.snapshot @@ -15,18 +15,18 @@ ok 1 - Coverage Print Fixed Width 100 # duration_ms * # start of coverage report # -------------------------------------------------------------------------------------------------- -# file | line % | branch % | funcs % | uncovered lines +# file | line % | branch % | funcs % | uncovered lines # -------------------------------------------------------------------------------------------------- -# test | | | | -# fixtures | | | | -# test-runner | | | | -# coverage-snap | | | | -# a.js | 55.77 | 100.00 | 0.00 | 5-7 9-11 13-15 1… -# b.js | 45.45 | 100.00 | 0.00 | 5-7 9-11 -# many-uncovered-lines.js | 50.99 | 42.86 | 1.92 | 5-7 9-11 13-15 1… -# output | | | | -# coverage-width-80-uncovered-lines.mjs | 100.00 | 100.00 | 100.00 | +# test | | | | +# fixtures | | | | +# test-runner | | | | +# coverage-snap | | | | +# a.js | 55.77 | 100.00 | 0.00 | 5-7 9-11 13-15 17-19 … +# b.js | 45.45 | 100.00 | 0.00 | 5-7 9-11 +# many-uncovered-lines.js | 50.99 | 42.86 | 1.92 | 5-7 9-11 13-15 17-19 … +# output | | | | +# coverage-width-80-uncovered-lines.mjs | 100.00 | 100.00 | 100.00 | # -------------------------------------------------------------------------------------------------- -# all files | 52.80 | 60.00 | 1.61 | +# all files | 52.80 | 60.00 | 1.61 | # -------------------------------------------------------------------------------------------------- # end of coverage report diff --git a/test/fixtures/test-runner/output/coverage-width-80.snapshot b/test/fixtures/test-runner/output/coverage-width-80.snapshot index a694d9e9f586a4..13d52dae13c354 100644 --- a/test/fixtures/test-runner/output/coverage-width-80.snapshot +++ b/test/fixtures/test-runner/output/coverage-width-80.snapshot @@ -15,17 +15,17 @@ ok 1 - Coverage Print Fixed Width 80 # duration_ms * # start of coverage report # ------------------------------------------------------------------------------ -# file | line % | branch % | funcs % | uncovered li… +# file | line % | branch % | funcs % | uncovered lines # ------------------------------------------------------------------------------ -# test | | | | -# fixtures | | | | -# test-runner | | | | -# coverage-snap | | | | -# a.js | 55.77 | 100.00 | 0.00 | 5-7 9-11 13-… -# b.js | 45.45 | 100.00 | 0.00 | 5-7 9-11 -# output | | | | -# coverage-width-80.mjs | 100.00 | 100.00 | 100.00 | +# test | | | | +# fixtures | | | | +# test-runner | | | | +# coverage-snap | | | | +# a.js | 55.77 | 100.00 | 0.00 | 5-7 9-11 13-15 17… +# b.js | 45.45 | 100.00 | 0.00 | 5-7 9-11 +# output | | | | +# coverage-width-80.mjs | 100.00 | 100.00 | 100.00 | # ------------------------------------------------------------------------------ -# all files | 60.81 | 100.00 | 0.00 | +# all files | 60.81 | 100.00 | 0.00 | # ------------------------------------------------------------------------------ # end of coverage report diff --git a/test/fixtures/test-runner/output/coverage-width-infinity-uncovered-lines.snapshot b/test/fixtures/test-runner/output/coverage-width-infinity-uncovered-lines.snapshot index 4fb84389223448..3634f81c5c3c35 100644 --- a/test/fixtures/test-runner/output/coverage-width-infinity-uncovered-lines.snapshot +++ b/test/fixtures/test-runner/output/coverage-width-infinity-uncovered-lines.snapshot @@ -14,19 +14,19 @@ ok 1 - Coverage Print Fixed Width Infinity # todo 0 # duration_ms * # start of coverage report -# ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -# file | line % | branch % | funcs % | uncovered lines -# ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -# test | | | | -# fixtures | | | | -# test-runner | | | | -# coverage-snap | | | | -# a.js | 55.77 | 100.00 | 0.00 | 5-7 9-11 13-15 17-19 29-30 40-42 45-47 50-52 -# b.js | 45.45 | 100.00 | 0.00 | 5-7 9-11 -# 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 91-93 96-98 100-102 104-106 111-112 118-119 122-123 127-129 132-136 144-146 150 166-167 173 180 188-189 196-200 207-213 216-218 221-223 226-228 232 236-238 241-243 246-248 251-257 260-262 265-268 271-273 276-280 283-285 288-290 293-295 298-301 304-306 309-312 315-318 321-324 327-329 332-340 343-348 351-353 -# output | | | | -# coverage-width-infinity-uncovered-lines.mjs | 100.00 | 100.00 | 100.00 | -# ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -# all files | 52.80 | 60.00 | 1.61 | -# ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +# file | line % | branch % | funcs % | uncovered lines +# -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +# test | | | | +# fixtures | | | | +# test-runner | | | | +# coverage-snap | | | | +# a.js | 55.77 | 100.00 | 0.00 | 5-7 9-11 13-15 17-19 29-30 40-42 45-47 50-52 +# b.js | 45.45 | 100.00 | 0.00 | 5-7 9-11 +# 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 91-93 96-98 100-102 104-106 111-112 118-119 122-123 127-129 132-136 144-146 150 166-167 173 180 188-189 196-200 207-213 216-218 221-223 226-228 232 236-238 241-243 246-248 251-257 260-262 265-268 271-273 276-280 283-285 288-290 293-295 298-301 304-306 309-312 315-318 321-324 327-329 332-340 343-348 351-353 +# output | | | | +# coverage-width-infinity-uncovered-lines.mjs | 100.00 | 100.00 | 100.00 | +# -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +# all files | 52.80 | 60.00 | 1.61 | +# -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- # end of coverage report diff --git a/test/fixtures/test-runner/output/coverage-width-infinity.snapshot b/test/fixtures/test-runner/output/coverage-width-infinity.snapshot index f9c13f5707dbc6..47481db9fe8d26 100644 --- a/test/fixtures/test-runner/output/coverage-width-infinity.snapshot +++ b/test/fixtures/test-runner/output/coverage-width-infinity.snapshot @@ -14,18 +14,18 @@ ok 1 - Coverage Print Fixed Width Infinity # todo 0 # duration_ms * # start of coverage report -# ------------------------------------------------------------------------------------------------------------------- -# file | line % | branch % | funcs % | uncovered lines -# ------------------------------------------------------------------------------------------------------------------- -# test | | | | -# fixtures | | | | -# test-runner | | | | -# coverage-snap | | | | -# a.js | 55.77 | 100.00 | 0.00 | 5-7 9-11 13-15 17-19 29-30 40-42 45-47 50-52 -# b.js | 45.45 | 100.00 | 0.00 | 5-7 9-11 -# output | | | | -# coverage-width-infinity.mjs | 100.00 | 100.00 | 100.00 | -# ------------------------------------------------------------------------------------------------------------------- -# all files | 60.81 | 100.00 | 0.00 | -# ------------------------------------------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------------------------------------- +# file | line % | branch % | funcs % | uncovered lines +# -------------------------------------------------------------------------------------------------------------- +# test | | | | +# fixtures | | | | +# test-runner | | | | +# coverage-snap | | | | +# a.js | 55.77 | 100.00 | 0.00 | 5-7 9-11 13-15 17-19 29-30 40-42 45-47 50-52 +# b.js | 45.45 | 100.00 | 0.00 | 5-7 9-11 +# output | | | | +# coverage-width-infinity.mjs | 100.00 | 100.00 | 100.00 | +# -------------------------------------------------------------------------------------------------------------- +# all files | 60.81 | 100.00 | 0.00 | +# -------------------------------------------------------------------------------------------------------------- # end of coverage report