From 1b90a221d540354c552da10d90ef7d1f7a8e8227 Mon Sep 17 00:00:00 2001 From: "Benjamin E. Coe" Date: Wed, 14 Oct 2020 19:31:08 -0700 Subject: [PATCH] fix: support node@v15.x.x built-in modules (#265) --- .nycrc | 6 ++-- lib/report.js | 5 +++ test/integration.js.snap | 12 +++---- test/integration.js_10.snap | 64 ++++++++++++++++++------------------- 4 files changed, 46 insertions(+), 41 deletions(-) diff --git a/.nycrc b/.nycrc index ccd5432e..6a4e6fd7 100644 --- a/.nycrc +++ b/.nycrc @@ -3,7 +3,7 @@ "html", "text" ], - "lines": 96, + "lines": 95, "branches": "82", - "statements": "96" - } \ No newline at end of file + "statements": "95" + } diff --git a/lib/report.js b/lib/report.js index 1d1ddbf5..5466dcd0 100644 --- a/lib/report.js +++ b/lib/report.js @@ -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) diff --git a/test/integration.js.snap b/test/integration.js.snap index 57203112..fd560c68 100644 --- a/test/integration.js.snap +++ b/test/integration.js.snap @@ -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%) " `; @@ -146,7 +146,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%) " `; @@ -154,7 +154,7 @@ 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 " `; @@ -162,7 +162,7 @@ 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%) " `; @@ -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%) " `; diff --git a/test/integration.js_10.snap b/test/integration.js_10.snap index c35e9e02..0fa2d5bd 100644 --- a/test/integration.js_10.snap +++ b/test/integration.js_10.snap @@ -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 @@ -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%) " `; @@ -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 @@ -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%) " `; @@ -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 @@ -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 @@ -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%) " `;