Skip to content

Commit

Permalink
fix: support [email protected] built-in modules (#265)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe authored Oct 15, 2020
1 parent 99bdc6d commit 1b90a22
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 41 deletions.
6 changes: 3 additions & 3 deletions .nycrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"html",
"text"
],
"lines": 96,
"lines": 95,
"branches": "82",
"statements": "96"
}
"statements": "95"
}
5 changes: 5 additions & 0 deletions lib/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,11 @@ class Report {
_normalizeProcessCov (v8ProcessCov, fileIndex) {
const result = []
for (const v8ScriptCov of v8ProcessCov.result) {
// https://github.com/nodejs/node/pull/35498 updates Node.js'
// builtin module filenames:
if (/^node:/.test(v8ScriptCov.url)) {
v8ScriptCov.url = `${v8ScriptCov.url.replace(/^node:/, '')}.js`
}
if (/^file:\/\//.test(v8ScriptCov.url)) {
try {
v8ScriptCov.url = furi.toSysPath(v8ScriptCov.url)
Expand Down
12 changes: 6 additions & 6 deletions test/integration.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@ All files | 64.29 | 66.67 | 50 | 64.29 |
--------------|---------|----------|---------|---------|-------------------
,ERROR: Coverage for lines (64.29%) does not meet global threshold (100%)
ERROR: Coverage for branches (66.67%) does not meet global threshold (82%)
ERROR: Coverage for statements (64.29%) does not meet global threshold (96%)
ERROR: Coverage for statements (64.29%) does not meet global threshold (95%)
"
`;

exports[`c8 --all should allow for --all to be used with the check-coverage command (2 invocations) 1`] = `
",,ERROR: Coverage for lines (64.29%) does not meet global threshold (90%)
ERROR: Coverage for branches (66.67%) does not meet global threshold (82%)
ERROR: Coverage for statements (64.29%) does not meet global threshold (96%)
ERROR: Coverage for statements (64.29%) does not meet global threshold (95%)
"
`;

Expand Down Expand Up @@ -146,23 +146,23 @@ All files | 83.33 | 85.71 | 60 | 83.33 |
normal.js | 75 | 66.67 | 33.33 | 75 | 14-16,18-20
-----------|---------|----------|---------|---------|-------------------
,ERROR: Coverage for lines (83.33%) does not meet global threshold (101%)
ERROR: Coverage for statements (83.33%) does not meet global threshold (96%)
ERROR: Coverage for statements (83.33%) does not meet global threshold (95%)
"
`;

exports[`c8 check-coverage allows threshold to be applied on per-file basis 1`] = `
",,ERROR: Coverage for lines (100%) does not meet threshold (101%) for test/fixtures/async.js
ERROR: Coverage for lines (75%) does not meet threshold (101%) for test/fixtures/normal.js
ERROR: Coverage for branches (66.67%) does not meet threshold (82%) for test/fixtures/normal.js
ERROR: Coverage for statements (75%) does not meet threshold (96%) for test/fixtures/normal.js
ERROR: Coverage for statements (75%) does not meet threshold (95%) for test/fixtures/normal.js
"
`;

exports[`c8 check-coverage exits with 0 if coverage within threshold 1`] = `",,"`;

exports[`c8 check-coverage exits with 1 if coverage is below threshold 1`] = `
",,ERROR: Coverage for lines (83.33%) does not meet global threshold (101%)
ERROR: Coverage for statements (83.33%) does not meet global threshold (96%)
ERROR: Coverage for statements (83.33%) does not meet global threshold (95%)
"
`;

Expand Down Expand Up @@ -250,7 +250,7 @@ All files | 83.33 | 85.71 | 60 | 83.33 |
normal.js | 75 | 66.67 | 33.33 | 75 | 14-16,18-20
-----------|---------|----------|---------|---------|-------------------
,ERROR: Coverage for lines (83.33%) does not meet global threshold (101%)
ERROR: Coverage for statements (83.33%) does not meet global threshold (96%)
ERROR: Coverage for statements (83.33%) does not meet global threshold (95%)
"
`;
Expand Down
64 changes: 32 additions & 32 deletions test/integration.js_10.snap
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ covered
--------------------------|---------|----------|---------|---------|--------------------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
--------------------------|---------|----------|---------|---------|--------------------------------
All files | 76.3 | 61.9 | 68.57 | 76.3 |
All files | 76.18 | 61.18 | 68.57 | 76.18 |
bin | 78.85 | 60 | 66.67 | 78.85 |
c8.js | 78.85 | 60 | 66.67 | 78.85 | 22,27-29,32-33,41-43,50-51
lib | 80.89 | 53.7 | 84.21 | 80.89 |
lib | 80.67 | 52.73 | 84.21 | 80.67 |
is-cjs-esm-bridge.js | 90 | 25 | 100 | 90 | 9
parse-args.js | 96.13 | 45.45 | 100 | 96.13 | 109-110,118-119,132-133
report.js | 75.44 | 61.76 | 84.62 | 75.44 | ...167,173-206,237-238,266-268
report.js | 75.17 | 60 | 84.62 | 75.17 | ...206,237-238,264-265,271-273
source-map-from-file.js | 44 | 100 | 0 | 44 | 10-23
lib/commands | 44.44 | 75 | 16.67 | 44.44 |
check-coverage.js | 21.31 | 100 | 0 | 21.31 | 9-11,14-27,30-44,46-61
Expand Down Expand Up @@ -102,14 +102,14 @@ All files | 64.29 | 66.67 | 50 | 64.29 |
--------------|---------|----------|---------|---------|-------------------
,ERROR: Coverage for lines (64.29%) does not meet global threshold (100%)
ERROR: Coverage for branches (66.67%) does not meet global threshold (82%)
ERROR: Coverage for statements (64.29%) does not meet global threshold (96%)
ERROR: Coverage for statements (64.29%) does not meet global threshold (95%)
"
`;

exports[`c8 --all should allow for --all to be used with the check-coverage command (2 invocations) 1`] = `
",,ERROR: Coverage for lines (64.29%) does not meet global threshold (90%)
ERROR: Coverage for branches (66.67%) does not meet global threshold (82%)
ERROR: Coverage for statements (64.29%) does not meet global threshold (96%)
ERROR: Coverage for statements (64.29%) does not meet global threshold (95%)
"
`;

Expand Down Expand Up @@ -140,13 +140,13 @@ hey
--------------------------|---------|----------|---------|---------|--------------------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
--------------------------|---------|----------|---------|---------|--------------------------------
All files | 75.81 | 59.49 | 67.65 | 75.81 |
All files | 75.69 | 58.75 | 67.65 | 75.69 |
bin | 78.85 | 60 | 66.67 | 78.85 |
c8.js | 78.85 | 60 | 66.67 | 78.85 | 22,27-29,32-33,41-43,50-51
lib | 80.89 | 53.7 | 84.21 | 80.89 |
lib | 80.67 | 52.73 | 84.21 | 80.67 |
is-cjs-esm-bridge.js | 90 | 25 | 100 | 90 | 9
parse-args.js | 96.13 | 45.45 | 100 | 96.13 | 109-110,118-119,132-133
report.js | 75.44 | 61.76 | 84.62 | 75.44 | ...167,173-206,237-238,266-268
report.js | 75.17 | 60 | 84.62 | 75.17 | ...206,237-238,264-265,271-273
source-map-from-file.js | 44 | 100 | 0 | 44 | 10-23
lib/commands | 44.44 | 75 | 16.67 | 44.44 |
check-coverage.js | 21.31 | 100 | 0 | 21.31 | 9-11,14-27,30-44,46-61
Expand All @@ -155,44 +155,44 @@ All files | 75.81 | 59.49 | 67.65 | 75.81 |
async.js | 100 | 100 | 100 | 100 |
normal.js | 75 | 66.67 | 33.33 | 75 | 14-16,18-20
--------------------------|---------|----------|---------|---------|--------------------------------
,ERROR: Coverage for lines (75.81%) does not meet global threshold (101%)
ERROR: Coverage for branches (59.49%) does not meet global threshold (82%)
ERROR: Coverage for statements (75.81%) does not meet global threshold (96%)
,ERROR: Coverage for lines (75.69%) does not meet global threshold (101%)
ERROR: Coverage for branches (58.75%) does not meet global threshold (82%)
ERROR: Coverage for statements (75.69%) does not meet global threshold (95%)
"
`;

exports[`c8 check-coverage allows threshold to be applied on per-file basis 1`] = `
",,ERROR: Coverage for lines (78.85%) does not meet threshold (101%) for bin/c8.js
ERROR: Coverage for branches (60%) does not meet threshold (82%) for bin/c8.js
ERROR: Coverage for statements (78.85%) does not meet threshold (96%) for bin/c8.js
ERROR: Coverage for statements (78.85%) does not meet threshold (95%) for bin/c8.js
ERROR: Coverage for lines (21.31%) does not meet threshold (101%) for lib/commands/check-coverage.js
ERROR: Coverage for statements (21.31%) does not meet threshold (96%) for lib/commands/check-coverage.js
ERROR: Coverage for statements (21.31%) does not meet threshold (95%) for lib/commands/check-coverage.js
ERROR: Coverage for lines (93.1%) does not meet threshold (101%) for lib/commands/report.js
ERROR: Coverage for branches (71.43%) does not meet threshold (82%) for lib/commands/report.js
ERROR: Coverage for statements (93.1%) does not meet threshold (96%) for lib/commands/report.js
ERROR: Coverage for statements (93.1%) does not meet threshold (95%) for lib/commands/report.js
ERROR: Coverage for lines (90%) does not meet threshold (101%) for lib/is-cjs-esm-bridge.js
ERROR: Coverage for branches (25%) does not meet threshold (82%) for lib/is-cjs-esm-bridge.js
ERROR: Coverage for statements (90%) does not meet threshold (96%) for lib/is-cjs-esm-bridge.js
ERROR: Coverage for statements (90%) does not meet threshold (95%) for lib/is-cjs-esm-bridge.js
ERROR: Coverage for lines (96.13%) does not meet threshold (101%) for lib/parse-args.js
ERROR: Coverage for branches (45.45%) does not meet threshold (82%) for lib/parse-args.js
ERROR: Coverage for lines (75.44%) does not meet threshold (101%) for lib/report.js
ERROR: Coverage for branches (61.76%) does not meet threshold (82%) for lib/report.js
ERROR: Coverage for statements (75.44%) does not meet threshold (96%) for lib/report.js
ERROR: Coverage for lines (75.17%) does not meet threshold (101%) for lib/report.js
ERROR: Coverage for branches (60%) does not meet threshold (82%) for lib/report.js
ERROR: Coverage for statements (75.17%) does not meet threshold (95%) for lib/report.js
ERROR: Coverage for lines (44%) does not meet threshold (101%) for lib/source-map-from-file.js
ERROR: Coverage for statements (44%) does not meet threshold (96%) for lib/source-map-from-file.js
ERROR: Coverage for statements (44%) does not meet threshold (95%) for lib/source-map-from-file.js
ERROR: Coverage for lines (100%) does not meet threshold (101%) for test/fixtures/async.js
ERROR: Coverage for lines (75%) does not meet threshold (101%) for test/fixtures/normal.js
ERROR: Coverage for branches (66.67%) does not meet threshold (82%) for test/fixtures/normal.js
ERROR: Coverage for statements (75%) does not meet threshold (96%) for test/fixtures/normal.js
ERROR: Coverage for statements (75%) does not meet threshold (95%) for test/fixtures/normal.js
"
`;

exports[`c8 check-coverage exits with 0 if coverage within threshold 1`] = `",,"`;

exports[`c8 check-coverage exits with 1 if coverage is below threshold 1`] = `
",,ERROR: Coverage for lines (75.81%) does not meet global threshold (101%)
ERROR: Coverage for branches (59.49%) does not meet global threshold (82%)
ERROR: Coverage for statements (75.81%) does not meet global threshold (96%)
",,ERROR: Coverage for lines (75.69%) does not meet global threshold (101%)
ERROR: Coverage for branches (58.75%) does not meet global threshold (82%)
ERROR: Coverage for statements (75.69%) does not meet global threshold (95%)
"
`;

Expand Down Expand Up @@ -264,13 +264,13 @@ exports[`c8 report generates report from existing temporary files 1`] = `
",--------------------------|---------|----------|---------|---------|--------------------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
--------------------------|---------|----------|---------|---------|--------------------------------
All files | 75.81 | 59.49 | 67.65 | 75.81 |
All files | 75.69 | 58.75 | 67.65 | 75.69 |
bin | 78.85 | 60 | 66.67 | 78.85 |
c8.js | 78.85 | 60 | 66.67 | 78.85 | 22,27-29,32-33,41-43,50-51
lib | 80.89 | 53.7 | 84.21 | 80.89 |
lib | 80.67 | 52.73 | 84.21 | 80.67 |
is-cjs-esm-bridge.js | 90 | 25 | 100 | 90 | 9
parse-args.js | 96.13 | 45.45 | 100 | 96.13 | 109-110,118-119,132-133
report.js | 75.44 | 61.76 | 84.62 | 75.44 | ...167,173-206,237-238,266-268
report.js | 75.17 | 60 | 84.62 | 75.17 | ...206,237-238,264-265,271-273
source-map-from-file.js | 44 | 100 | 0 | 44 | 10-23
lib/commands | 44.44 | 75 | 16.67 | 44.44 |
check-coverage.js | 21.31 | 100 | 0 | 21.31 | 9-11,14-27,30-44,46-61
Expand All @@ -286,13 +286,13 @@ exports[`c8 report supports --check-coverage, when generating reports 1`] = `
",--------------------------|---------|----------|---------|---------|--------------------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
--------------------------|---------|----------|---------|---------|--------------------------------
All files | 75.81 | 59.49 | 67.65 | 75.81 |
All files | 75.69 | 58.75 | 67.65 | 75.69 |
bin | 78.85 | 60 | 66.67 | 78.85 |
c8.js | 78.85 | 60 | 66.67 | 78.85 | 22,27-29,32-33,41-43,50-51
lib | 80.89 | 53.7 | 84.21 | 80.89 |
lib | 80.67 | 52.73 | 84.21 | 80.67 |
is-cjs-esm-bridge.js | 90 | 25 | 100 | 90 | 9
parse-args.js | 96.13 | 45.45 | 100 | 96.13 | 109-110,118-119,132-133
report.js | 75.44 | 61.76 | 84.62 | 75.44 | ...167,173-206,237-238,266-268
report.js | 75.17 | 60 | 84.62 | 75.17 | ...206,237-238,264-265,271-273
source-map-from-file.js | 44 | 100 | 0 | 44 | 10-23
lib/commands | 44.44 | 75 | 16.67 | 44.44 |
check-coverage.js | 21.31 | 100 | 0 | 21.31 | 9-11,14-27,30-44,46-61
Expand All @@ -301,9 +301,9 @@ All files | 75.81 | 59.49 | 67.65 | 75.81 |
async.js | 100 | 100 | 100 | 100 |
normal.js | 75 | 66.67 | 33.33 | 75 | 14-16,18-20
--------------------------|---------|----------|---------|---------|--------------------------------
,ERROR: Coverage for lines (75.81%) does not meet global threshold (101%)
ERROR: Coverage for branches (59.49%) does not meet global threshold (82%)
ERROR: Coverage for statements (75.81%) does not meet global threshold (96%)
,ERROR: Coverage for lines (75.69%) does not meet global threshold (101%)
ERROR: Coverage for branches (58.75%) does not meet global threshold (82%)
ERROR: Coverage for statements (75.69%) does not meet global threshold (95%)
"
`;
Expand Down

0 comments on commit 1b90a22

Please sign in to comment.