Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(v8-to-istanbul): pull in fix for missing branches #258

Merged
merged 1 commit into from Oct 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -43,7 +43,7 @@
"istanbul-reports": "^3.0.2",
"rimraf": "^3.0.0",
"test-exclude": "^6.0.0",
"v8-to-istanbul": "^5.0.0",
"v8-to-istanbul": "^6.0.0",
"yargs": "^16.0.0",
"yargs-parser": "^20.0.0"
},
Expand Down
7 changes: 7 additions & 0 deletions test/fixtures/issue-254.js
@@ -0,0 +1,7 @@
function fn() {
return true;
/* c8 ignore next */
console.log('never runs');
}

fn();
20 changes: 14 additions & 6 deletions test/integration.js
Expand Up @@ -278,6 +278,20 @@ describe('c8', () => {
])
output.toString('utf8').should.matchSnapshot()
})

// see: https://github.com/bcoe/c8/issues/254
it('does not incorrectly mark previous branch as uncovered (see #254)', () => {
const { output } = spawnSync(nodePath, [
c8Path,
'--exclude="test/*.js"',
'--temp-directory=tmp/issue-254',
'--clean=true',
'--reporter=text',
nodePath,
require.resolve('./fixtures/issue-254')
])
output.toString('utf8').should.matchSnapshot()
})
})

describe('source-maps', () => {
Expand Down Expand Up @@ -344,9 +358,6 @@ describe('c8', () => {
})

describe('nyc', () => {
// Bugs:
// first 'if' statement indicates two odd missing branches.
// line 4 should be covered.
it('remaps branches', () => {
const { output } = spawnSync(nodePath, [
c8Path,
Expand All @@ -359,9 +370,6 @@ describe('c8', () => {
output.toString('utf8').should.matchSnapshot()
})

// Bugs:
// the portion `class F` of `class Foo` indicates missing branch.
// line 6 should be covered.
it('remaps classes', () => {
const { output } = spawnSync(nodePath, [
c8Path,
Expand Down
54 changes: 32 additions & 22 deletions test/integration.js.snap
@@ -1,5 +1,15 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`c8 /* c8 ignore next */ does not incorrectly mark previous branch as uncovered (see #254) 1`] = `
",--------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
--------------|---------|----------|---------|---------|-------------------
All files | 100 | 100 | 100 | 100 |
issue-254.js | 100 | 100 | 100 | 100 |
--------------|---------|----------|---------|---------|-------------------
,"
`;

exports[`c8 /* c8 ignore next */ ignores lines with special comment 1`] = `
",covered
covered
Expand Down Expand Up @@ -38,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
Expand All @@ -55,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
Expand Down Expand Up @@ -326,8 +336,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
------------------------|---------|----------|---------|---------|-------------------
,"
`;
Expand All @@ -341,8 +351,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
-----------------------|---------|----------|---------|---------|-------------------
,"
`;
Expand All @@ -354,8 +364,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
-------------|---------|----------|---------|---------|-------------------
,"
`;
Expand All @@ -369,8 +379,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
------------|---------|----------|---------|---------|-------------------
,"
`;
Expand All @@ -392,8 +402,8 @@ a = false
-------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
-------------|---------|----------|---------|---------|-------------------
All files | 75 | 55.56 | 100 | 75 |
branches.js | 75 | 55.56 | 100 | 75 | 4-7,13
All files | 80 | 40 | 100 | 80 |
branches.js | 80 | 40 | 100 | 80 | 2,6-7,13
-------------|---------|----------|---------|---------|-------------------
,"
`;
Expand All @@ -407,8 +417,8 @@ covered
------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
------------|---------|----------|---------|---------|-------------------
All files | 70.37 | 80 | 71.43 | 70.37 |
classes.js | 70.37 | 80 | 71.43 | 70.37 | 5-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
------------|---------|----------|---------|---------|-------------------
,"
`;
Expand Down Expand Up @@ -436,9 +446,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
------------|---------|----------|---------|---------|-------------------
,"
`;
Expand All @@ -452,8 +462,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
------------------|---------|----------|---------|---------|-------------------
,"
`;
Expand Down
32 changes: 21 additions & 11 deletions test/integration.js_10.snap
@@ -1,5 +1,15 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`c8 /* c8 ignore next */ does not incorrectly mark previous branch as uncovered (see #254) 1`] = `
",--------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
--------------|---------|----------|---------|---------|-------------------
All files | 100 | 100 | 100 | 100 |
issue-254.js | 100 | 100 | 100 | 100 |
--------------|---------|----------|---------|---------|-------------------
,"
`;

exports[`c8 /* c8 ignore next */ ignores lines with special comment 1`] = `
",covered
covered
Expand Down Expand Up @@ -49,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
Expand Down Expand Up @@ -394,8 +404,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
-----------------------|---------|----------|---------|---------|-------------------
,"
`;
Expand Down Expand Up @@ -445,8 +455,8 @@ a = false
-------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
-------------|---------|----------|---------|---------|-------------------
All files | 75 | 55.56 | 100 | 75 |
branches.js | 75 | 55.56 | 100 | 75 | 4-7,13
All files | 80 | 40 | 100 | 80 |
branches.js | 80 | 40 | 100 | 80 | 2,6-7,13
-------------|---------|----------|---------|---------|-------------------
,"
`;
Expand All @@ -460,8 +470,8 @@ covered
------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
------------|---------|----------|---------|---------|-------------------
All files | 70.37 | 80 | 71.43 | 70.37 |
classes.js | 70.37 | 80 | 71.43 | 70.37 | 5-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
------------|---------|----------|---------|---------|-------------------
,"
`;
Expand Down Expand Up @@ -489,9 +499,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
------------|---------|----------|---------|---------|-------------------
,"
`;
Expand Down