diff --git a/package-lock.json b/package-lock.json index d270c785..22782ac4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2951,9 +2951,9 @@ "dev": true }, "v8-to-istanbul": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-6.0.1.tgz", - "integrity": "sha512-PzM1WlqquhBvsV+Gco6WSFeg1AGdD53ccMRkFeyHRE/KRZaVacPOmQYP3EeVgDBtKD2BJ8kgynBQ5OtKiHCH+w==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-7.0.0.tgz", + "integrity": "sha512-fLL2rFuQpMtm9r8hrAV2apXX/WqHJ6+IC4/eQVdMDGBUgH/YMV4Gv3duk3kjmyg6uiQWBAA9nJwue4iJUOkHeA==", "requires": { "@types/istanbul-lib-coverage": "^2.0.1", "convert-source-map": "^1.6.0", diff --git a/package.json b/package.json index 7bf613e2..68ad54e6 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "istanbul-reports": "^3.0.2", "rimraf": "^3.0.0", "test-exclude": "^6.0.0", - "v8-to-istanbul": "^6.0.1", + "v8-to-istanbul": "^7.0.0", "yargs": "^16.0.0", "yargs-parser": "^20.0.0" }, diff --git a/test/fixtures/shebang.js b/test/fixtures/shebang.js new file mode 100755 index 00000000..195fa165 --- /dev/null +++ b/test/fixtures/shebang.js @@ -0,0 +1,8 @@ +#!/usr/bin/env node +'use strict' + +if (true) { + console.info('hello world') +} else { + console.info('goodnight moon') +} diff --git a/test/integration.js b/test/integration.js index 835bb69b..def53a94 100644 --- a/test/integration.js +++ b/test/integration.js @@ -561,4 +561,15 @@ describe('c8', () => { output.toString('utf8').should.matchSnapshot() }) }) + + it('collects coverage for script with shebang', () => { + const { output } = spawnSync(nodePath, [ + c8Path, + '--exclude="test/*.js"', + '--temp-directory=tmp/shebang', + '--clean=false', + require.resolve('./fixtures/shebang') + ]) + output.toString('utf8').should.matchSnapshot() + }) }) diff --git a/test/integration.js.snap b/test/integration.js.snap index fd560c68..93e4fbb8 100644 --- a/test/integration.js.snap +++ b/test/integration.js.snap @@ -4,8 +4,8 @@ exports[`c8 /* c8 ignore next */ does not incorrectly mark previous branch as un ",--------------|---------|----------|---------|---------|------------------- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s --------------|---------|----------|---------|---------|------------------- -All files | 100 | 66.67 | 100 | 100 | - issue-254.js | 100 | 66.67 | 100 | 100 | 2 +All files | 100 | 100 | 100 | 100 | + issue-254.js | 100 | 100 | 100 | 100 | --------------|---------|----------|---------|---------|------------------- ," `; @@ -48,9 +48,9 @@ negative -----------------|---------|----------|---------|---------|------------------- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s -----------------|---------|----------|---------|---------|------------------- -All files | 64.29 | 66.67 | 50 | 64.29 | - ts-compiled | 78.26 | 75 | 100 | 78.26 | - loaded.ts | 73.68 | 71.43 | 100 | 73.68 | 4-5,16-18 +All files | 64.29 | 57.14 | 50 | 64.29 | + ts-compiled | 78.26 | 66.67 | 100 | 78.26 | + loaded.ts | 73.68 | 66.67 | 100 | 73.68 | 4-5,16-18 main.ts | 100 | 100 | 100 | 100 | ts-compiled/dir | 0 | 0 | 0 | 0 | unloaded.ts | 0 | 0 | 0 | 0 | 1-5 @@ -65,9 +65,9 @@ negative --------------|---------|----------|---------|---------|------------------- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s --------------|---------|----------|---------|---------|------------------- -All files | 64.29 | 66.67 | 50 | 64.29 | - ts-only | 78.26 | 75 | 100 | 78.26 | - loaded.ts | 73.68 | 71.43 | 100 | 73.68 | 4-5,16-18 +All files | 64.29 | 57.14 | 50 | 64.29 | + ts-only | 78.26 | 66.67 | 100 | 78.26 | + loaded.ts | 73.68 | 66.67 | 100 | 73.68 | 4-5,16-18 main.ts | 100 | 100 | 100 | 100 | ts-only/dir | 0 | 0 | 0 | 0 | unloaded.ts | 0 | 0 | 0 | 0 | 1-5 @@ -215,6 +215,17 @@ exports[`c8 cobertura report escapes special characters 1`] = ` " `; +exports[`c8 collects coverage for script with shebang 1`] = ` +",hello world +------------|---------|----------|---------|---------|------------------- +File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s +------------|---------|----------|---------|---------|------------------- +All files | 75 | 50 | 100 | 75 | + shebang.js | 75 | 50 | 100 | 75 | 7-8 +------------|---------|----------|---------|---------|------------------- +," +`; + exports[`c8 merges reports from subprocesses together 1`] = ` ",first @@ -336,8 +347,8 @@ a = false ------------------------|---------|----------|---------|---------|------------------- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s ------------------------|---------|----------|---------|---------|------------------- -All files | 84 | 57.14 | 100 | 84 | - branches.typescript.ts | 84 | 57.14 | 100 | 84 | 7,11-12,18 +All files | 84 | 50 | 100 | 84 | + branches.typescript.ts | 84 | 50 | 100 | 84 | 7,11-12,18 ------------------------|---------|----------|---------|---------|------------------- ," `; @@ -351,8 +362,8 @@ covered -----------------------|---------|----------|---------|---------|------------------- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s -----------------------|---------|----------|---------|---------|------------------- -All files | 81.82 | 87.5 | 60 | 81.82 | - classes.typescript.ts | 81.82 | 87.5 | 60 | 81.82 | 12-13,21-22,27-28 +All files | 81.82 | 85.71 | 60 | 81.82 | + classes.typescript.ts | 81.82 | 85.71 | 60 | 81.82 | 12-13,21-22,27-28 -----------------------|---------|----------|---------|---------|------------------- ," `; @@ -364,8 +375,8 @@ a = false -------------|---------|----------|---------|---------|------------------- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s -------------|---------|----------|---------|---------|------------------- -All files | 80 | 50 | 100 | 80 | - branches.js | 80 | 50 | 100 | 80 | 2,5-6,13 +All files | 80 | 40 | 100 | 80 | + branches.js | 80 | 40 | 100 | 80 | 2,5-6,13 -------------|---------|----------|---------|---------|------------------- ," `; @@ -379,8 +390,8 @@ covered ------------|---------|----------|---------|---------|------------------- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s ------------|---------|----------|---------|---------|------------------- -All files | 85.19 | 83.33 | 60 | 85.19 | - classes.js | 85.19 | 83.33 | 60 | 85.19 | 6-7,15,21 +All files | 85.19 | 80 | 60 | 85.19 | + classes.js | 85.19 | 80 | 60 | 85.19 | 6-7,15,21 ------------|---------|----------|---------|---------|------------------- ," `; @@ -402,8 +413,8 @@ a = false -------------|---------|----------|---------|---------|------------------- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s -------------|---------|----------|---------|---------|------------------- -All files | 80 | 55.56 | 100 | 80 | - branches.js | 80 | 55.56 | 100 | 80 | 2,6-7,13 +All files | 80 | 40 | 100 | 80 | + branches.js | 80 | 40 | 100 | 80 | 2,6-7,13 -------------|---------|----------|---------|---------|------------------- ," `; @@ -417,8 +428,8 @@ covered ------------|---------|----------|---------|---------|------------------- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s ------------|---------|----------|---------|---------|------------------- -All files | 77.78 | 80 | 71.43 | 77.78 | - classes.js | 77.78 | 80 | 71.43 | 77.78 | 7-8,15-16,21-22 +All files | 77.78 | 83.33 | 60 | 77.78 | + classes.js | 77.78 | 83.33 | 60 | 77.78 | 7-8,15-16,21-22 ------------|---------|----------|---------|---------|------------------- ," `; @@ -446,9 +457,9 @@ covered ------------|---------|----------|---------|---------|------------------- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s ------------|---------|----------|---------|---------|------------------- -All files | 78.57 | 85.71 | 60 | 78.57 | +All files | 78.57 | 83.33 | 60 | 78.57 | class-1.js | 100 | 100 | 100 | 100 | - class-2.js | 73.91 | 85.71 | 60 | 73.91 | 7-8,15-16,21-22 + class-2.js | 73.91 | 83.33 | 60 | 73.91 | 7-8,15-16,21-22 ------------|---------|----------|---------|---------|------------------- ," `; @@ -462,8 +473,8 @@ covered ------------------|---------|----------|---------|---------|------------------- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s ------------------|---------|----------|---------|---------|------------------- -All files | 88.24 | 87.5 | 80 | 88.24 | - ts-node-basic.ts | 88.24 | 87.5 | 80 | 88.24 | 12-13,28-29 +All files | 88.24 | 85.71 | 80 | 88.24 | + ts-node-basic.ts | 88.24 | 85.71 | 80 | 88.24 | 12-13,28-29 ------------------|---------|----------|---------|---------|------------------- ," `; diff --git a/test/integration.js_10.snap b/test/integration.js_10.snap index 0fa2d5bd..be0e8aab 100644 --- a/test/integration.js_10.snap +++ b/test/integration.js_10.snap @@ -4,8 +4,8 @@ exports[`c8 /* c8 ignore next */ does not incorrectly mark previous branch as un ",--------------|---------|----------|---------|---------|------------------- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s --------------|---------|----------|---------|---------|------------------- -All files | 100 | 66.67 | 100 | 100 | - issue-254.js | 100 | 66.67 | 100 | 100 | 2 +All files | 100 | 100 | 100 | 100 | + issue-254.js | 100 | 100 | 100 | 100 | --------------|---------|----------|---------|---------|------------------- ," `; @@ -59,9 +59,9 @@ negative -----------------|---------|----------|---------|---------|------------------- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s -----------------|---------|----------|---------|---------|------------------- -All files | 64.29 | 66.67 | 50 | 64.29 | - ts-compiled | 78.26 | 75 | 100 | 78.26 | - loaded.ts | 73.68 | 71.43 | 100 | 73.68 | 4-5,16-18 +All files | 64.29 | 57.14 | 50 | 64.29 | + ts-compiled | 78.26 | 66.67 | 100 | 78.26 | + loaded.ts | 73.68 | 66.67 | 100 | 73.68 | 4-5,16-18 main.ts | 100 | 100 | 100 | 100 | ts-compiled/dir | 0 | 0 | 0 | 0 | unloaded.ts | 0 | 0 | 0 | 0 | 1-5 @@ -245,6 +245,17 @@ exports[`c8 cobertura report escapes special characters 1`] = ` " `; +exports[`c8 collects coverage for script with shebang 1`] = ` +",hello world +------------|---------|----------|---------|---------|------------------- +File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s +------------|---------|----------|---------|---------|------------------- +All files | 75 | 50 | 100 | 75 | + shebang.js | 75 | 50 | 100 | 75 | 7-8 +------------|---------|----------|---------|---------|------------------- +," +`; + exports[`c8 merges reports from subprocesses together 1`] = ` ",first @@ -404,8 +415,8 @@ covered -----------------------|---------|----------|---------|---------|------------------- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s -----------------------|---------|----------|---------|---------|------------------- -All files | 81.82 | 87.5 | 60 | 81.82 | - classes.typescript.ts | 81.82 | 87.5 | 60 | 81.82 | 12-13,21-22,27-28 +All files | 81.82 | 85.71 | 60 | 81.82 | + classes.typescript.ts | 81.82 | 85.71 | 60 | 81.82 | 12-13,21-22,27-28 -----------------------|---------|----------|---------|---------|------------------- ," `; @@ -455,8 +466,8 @@ a = false -------------|---------|----------|---------|---------|------------------- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s -------------|---------|----------|---------|---------|------------------- -All files | 80 | 55.56 | 100 | 80 | - branches.js | 80 | 55.56 | 100 | 80 | 2,6-7,13 +All files | 80 | 40 | 100 | 80 | + branches.js | 80 | 40 | 100 | 80 | 2,6-7,13 -------------|---------|----------|---------|---------|------------------- ," `; @@ -470,8 +481,8 @@ covered ------------|---------|----------|---------|---------|------------------- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s ------------|---------|----------|---------|---------|------------------- -All files | 77.78 | 80 | 71.43 | 77.78 | - classes.js | 77.78 | 80 | 71.43 | 77.78 | 7-8,15-16,21-22 +All files | 77.78 | 83.33 | 60 | 77.78 | + classes.js | 77.78 | 83.33 | 60 | 77.78 | 7-8,15-16,21-22 ------------|---------|----------|---------|---------|------------------- ," `; @@ -499,9 +510,9 @@ covered ------------|---------|----------|---------|---------|------------------- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s ------------|---------|----------|---------|---------|------------------- -All files | 78.57 | 85.71 | 60 | 78.57 | +All files | 78.57 | 83.33 | 60 | 78.57 | class-1.js | 100 | 100 | 100 | 100 | - class-2.js | 73.91 | 85.71 | 60 | 73.91 | 7-8,15-16,21-22 + class-2.js | 73.91 | 83.33 | 60 | 73.91 | 7-8,15-16,21-22 ------------|---------|----------|---------|---------|------------------- ," `;