Skip to content

Commit eaffa78

Browse files
authored
fix(v8-to-istanbul): pull in fix for missing branches (bcoe#258)
1 parent 16e5824 commit eaffa78

File tree

6 files changed

+78
-43
lines changed

6 files changed

+78
-43
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"istanbul-reports": "^3.0.2",
4444
"rimraf": "^3.0.0",
4545
"test-exclude": "^6.0.0",
46-
"v8-to-istanbul": "^5.0.0",
46+
"v8-to-istanbul": "^6.0.0",
4747
"yargs": "^16.0.0",
4848
"yargs-parser": "^20.0.0"
4949
},

test/fixtures/issue-254.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
function fn() {
2+
return true;
3+
/* c8 ignore next */
4+
console.log('never runs');
5+
}
6+
7+
fn();

test/integration.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,20 @@ describe('c8', () => {
278278
])
279279
output.toString('utf8').should.matchSnapshot()
280280
})
281+
282+
// see: https://github.com/bcoe/c8/issues/254
283+
it('does not incorrectly mark previous branch as uncovered (see #254)', () => {
284+
const { output } = spawnSync(nodePath, [
285+
c8Path,
286+
'--exclude="test/*.js"',
287+
'--temp-directory=tmp/issue-254',
288+
'--clean=true',
289+
'--reporter=text',
290+
nodePath,
291+
require.resolve('./fixtures/issue-254')
292+
])
293+
output.toString('utf8').should.matchSnapshot()
294+
})
281295
})
282296

283297
describe('source-maps', () => {
@@ -344,9 +358,6 @@ describe('c8', () => {
344358
})
345359

346360
describe('nyc', () => {
347-
// Bugs:
348-
// first 'if' statement indicates two odd missing branches.
349-
// line 4 should be covered.
350361
it('remaps branches', () => {
351362
const { output } = spawnSync(nodePath, [
352363
c8Path,
@@ -359,9 +370,6 @@ describe('c8', () => {
359370
output.toString('utf8').should.matchSnapshot()
360371
})
361372

362-
// Bugs:
363-
// the portion `class F` of `class Foo` indicates missing branch.
364-
// line 6 should be covered.
365373
it('remaps classes', () => {
366374
const { output } = spawnSync(nodePath, [
367375
c8Path,

test/integration.js.snap

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`c8 /* c8 ignore next */ does not incorrectly mark previous branch as uncovered (see #254) 1`] = `
4+
",--------------|---------|----------|---------|---------|-------------------
5+
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
6+
--------------|---------|----------|---------|---------|-------------------
7+
All files | 100 | 100 | 100 | 100 |
8+
issue-254.js | 100 | 100 | 100 | 100 |
9+
--------------|---------|----------|---------|---------|-------------------
10+
,"
11+
`;
12+
313
exports[`c8 /* c8 ignore next */ ignores lines with special comment 1`] = `
414
",covered
515
covered
@@ -38,9 +48,9 @@ negative
3848
-----------------|---------|----------|---------|---------|-------------------
3949
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
4050
-----------------|---------|----------|---------|---------|-------------------
41-
All files | 64.29 | 66.67 | 50 | 64.29 |
42-
ts-compiled | 78.26 | 75 | 100 | 78.26 |
43-
loaded.ts | 73.68 | 71.43 | 100 | 73.68 | 4-5,16-18
51+
All files | 64.29 | 57.14 | 50 | 64.29 |
52+
ts-compiled | 78.26 | 66.67 | 100 | 78.26 |
53+
loaded.ts | 73.68 | 66.67 | 100 | 73.68 | 4-5,16-18
4454
main.ts | 100 | 100 | 100 | 100 |
4555
ts-compiled/dir | 0 | 0 | 0 | 0 |
4656
unloaded.ts | 0 | 0 | 0 | 0 | 1-5
@@ -55,9 +65,9 @@ negative
5565
--------------|---------|----------|---------|---------|-------------------
5666
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
5767
--------------|---------|----------|---------|---------|-------------------
58-
All files | 64.29 | 66.67 | 50 | 64.29 |
59-
ts-only | 78.26 | 75 | 100 | 78.26 |
60-
loaded.ts | 73.68 | 71.43 | 100 | 73.68 | 4-5,16-18
68+
All files | 64.29 | 57.14 | 50 | 64.29 |
69+
ts-only | 78.26 | 66.67 | 100 | 78.26 |
70+
loaded.ts | 73.68 | 66.67 | 100 | 73.68 | 4-5,16-18
6171
main.ts | 100 | 100 | 100 | 100 |
6272
ts-only/dir | 0 | 0 | 0 | 0 |
6373
unloaded.ts | 0 | 0 | 0 | 0 | 1-5
@@ -326,8 +336,8 @@ a = false
326336
------------------------|---------|----------|---------|---------|-------------------
327337
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
328338
------------------------|---------|----------|---------|---------|-------------------
329-
All files | 84 | 57.14 | 100 | 84 |
330-
branches.typescript.ts | 84 | 57.14 | 100 | 84 | 7,11-12,18
339+
All files | 84 | 50 | 100 | 84 |
340+
branches.typescript.ts | 84 | 50 | 100 | 84 | 7,11-12,18
331341
------------------------|---------|----------|---------|---------|-------------------
332342
,"
333343
`;
@@ -341,8 +351,8 @@ covered
341351
-----------------------|---------|----------|---------|---------|-------------------
342352
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
343353
-----------------------|---------|----------|---------|---------|-------------------
344-
All files | 81.82 | 87.5 | 60 | 81.82 |
345-
classes.typescript.ts | 81.82 | 87.5 | 60 | 81.82 | 12-13,21-22,27-28
354+
All files | 81.82 | 85.71 | 60 | 81.82 |
355+
classes.typescript.ts | 81.82 | 85.71 | 60 | 81.82 | 12-13,21-22,27-28
346356
-----------------------|---------|----------|---------|---------|-------------------
347357
,"
348358
`;
@@ -354,8 +364,8 @@ a = false
354364
-------------|---------|----------|---------|---------|-------------------
355365
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
356366
-------------|---------|----------|---------|---------|-------------------
357-
All files | 80 | 50 | 100 | 80 |
358-
branches.js | 80 | 50 | 100 | 80 | 2,5-6,13
367+
All files | 80 | 40 | 100 | 80 |
368+
branches.js | 80 | 40 | 100 | 80 | 2,5-6,13
359369
-------------|---------|----------|---------|---------|-------------------
360370
,"
361371
`;
@@ -369,8 +379,8 @@ covered
369379
------------|---------|----------|---------|---------|-------------------
370380
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
371381
------------|---------|----------|---------|---------|-------------------
372-
All files | 85.19 | 83.33 | 60 | 85.19 |
373-
classes.js | 85.19 | 83.33 | 60 | 85.19 | 6-7,15,21
382+
All files | 85.19 | 80 | 60 | 85.19 |
383+
classes.js | 85.19 | 80 | 60 | 85.19 | 6-7,15,21
374384
------------|---------|----------|---------|---------|-------------------
375385
,"
376386
`;
@@ -392,8 +402,8 @@ a = false
392402
-------------|---------|----------|---------|---------|-------------------
393403
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
394404
-------------|---------|----------|---------|---------|-------------------
395-
All files | 75 | 55.56 | 100 | 75 |
396-
branches.js | 75 | 55.56 | 100 | 75 | 4-7,13
405+
All files | 80 | 40 | 100 | 80 |
406+
branches.js | 80 | 40 | 100 | 80 | 2,6-7,13
397407
-------------|---------|----------|---------|---------|-------------------
398408
,"
399409
`;
@@ -407,8 +417,8 @@ covered
407417
------------|---------|----------|---------|---------|-------------------
408418
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
409419
------------|---------|----------|---------|---------|-------------------
410-
All files | 70.37 | 80 | 71.43 | 70.37 |
411-
classes.js | 70.37 | 80 | 71.43 | 70.37 | 5-8,15-16,21-22
420+
All files | 77.78 | 83.33 | 60 | 77.78 |
421+
classes.js | 77.78 | 83.33 | 60 | 77.78 | 7-8,15-16,21-22
412422
------------|---------|----------|---------|---------|-------------------
413423
,"
414424
`;
@@ -436,9 +446,9 @@ covered
436446
------------|---------|----------|---------|---------|-------------------
437447
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
438448
------------|---------|----------|---------|---------|-------------------
439-
All files | 78.57 | 85.71 | 60 | 78.57 |
449+
All files | 78.57 | 83.33 | 60 | 78.57 |
440450
class-1.js | 100 | 100 | 100 | 100 |
441-
class-2.js | 73.91 | 85.71 | 60 | 73.91 | 7-8,15-16,21-22
451+
class-2.js | 73.91 | 83.33 | 60 | 73.91 | 7-8,15-16,21-22
442452
------------|---------|----------|---------|---------|-------------------
443453
,"
444454
`;
@@ -452,8 +462,8 @@ covered
452462
------------------|---------|----------|---------|---------|-------------------
453463
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
454464
------------------|---------|----------|---------|---------|-------------------
455-
All files | 88.24 | 87.5 | 80 | 88.24 |
456-
ts-node-basic.ts | 88.24 | 87.5 | 80 | 88.24 | 12-13,28-29
465+
All files | 88.24 | 85.71 | 80 | 88.24 |
466+
ts-node-basic.ts | 88.24 | 85.71 | 80 | 88.24 | 12-13,28-29
457467
------------------|---------|----------|---------|---------|-------------------
458468
,"
459469
`;

test/integration.js_10.snap

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`c8 /* c8 ignore next */ does not incorrectly mark previous branch as uncovered (see #254) 1`] = `
4+
",--------------|---------|----------|---------|---------|-------------------
5+
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
6+
--------------|---------|----------|---------|---------|-------------------
7+
All files | 100 | 100 | 100 | 100 |
8+
issue-254.js | 100 | 100 | 100 | 100 |
9+
--------------|---------|----------|---------|---------|-------------------
10+
,"
11+
`;
12+
313
exports[`c8 /* c8 ignore next */ ignores lines with special comment 1`] = `
414
",covered
515
covered
@@ -49,9 +59,9 @@ negative
4959
-----------------|---------|----------|---------|---------|-------------------
5060
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
5161
-----------------|---------|----------|---------|---------|-------------------
52-
All files | 64.29 | 66.67 | 50 | 64.29 |
53-
ts-compiled | 78.26 | 75 | 100 | 78.26 |
54-
loaded.ts | 73.68 | 71.43 | 100 | 73.68 | 4-5,16-18
62+
All files | 64.29 | 57.14 | 50 | 64.29 |
63+
ts-compiled | 78.26 | 66.67 | 100 | 78.26 |
64+
loaded.ts | 73.68 | 66.67 | 100 | 73.68 | 4-5,16-18
5565
main.ts | 100 | 100 | 100 | 100 |
5666
ts-compiled/dir | 0 | 0 | 0 | 0 |
5767
unloaded.ts | 0 | 0 | 0 | 0 | 1-5
@@ -394,8 +404,8 @@ covered
394404
-----------------------|---------|----------|---------|---------|-------------------
395405
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
396406
-----------------------|---------|----------|---------|---------|-------------------
397-
All files | 81.82 | 87.5 | 60 | 81.82 |
398-
classes.typescript.ts | 81.82 | 87.5 | 60 | 81.82 | 12-13,21-22,27-28
407+
All files | 81.82 | 85.71 | 60 | 81.82 |
408+
classes.typescript.ts | 81.82 | 85.71 | 60 | 81.82 | 12-13,21-22,27-28
399409
-----------------------|---------|----------|---------|---------|-------------------
400410
,"
401411
`;
@@ -445,8 +455,8 @@ a = false
445455
-------------|---------|----------|---------|---------|-------------------
446456
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
447457
-------------|---------|----------|---------|---------|-------------------
448-
All files | 75 | 55.56 | 100 | 75 |
449-
branches.js | 75 | 55.56 | 100 | 75 | 4-7,13
458+
All files | 80 | 40 | 100 | 80 |
459+
branches.js | 80 | 40 | 100 | 80 | 2,6-7,13
450460
-------------|---------|----------|---------|---------|-------------------
451461
,"
452462
`;
@@ -460,8 +470,8 @@ covered
460470
------------|---------|----------|---------|---------|-------------------
461471
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
462472
------------|---------|----------|---------|---------|-------------------
463-
All files | 70.37 | 80 | 71.43 | 70.37 |
464-
classes.js | 70.37 | 80 | 71.43 | 70.37 | 5-8,15-16,21-22
473+
All files | 77.78 | 83.33 | 60 | 77.78 |
474+
classes.js | 77.78 | 83.33 | 60 | 77.78 | 7-8,15-16,21-22
465475
------------|---------|----------|---------|---------|-------------------
466476
,"
467477
`;
@@ -489,9 +499,9 @@ covered
489499
------------|---------|----------|---------|---------|-------------------
490500
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
491501
------------|---------|----------|---------|---------|-------------------
492-
All files | 78.57 | 85.71 | 60 | 78.57 |
502+
All files | 78.57 | 83.33 | 60 | 78.57 |
493503
class-1.js | 100 | 100 | 100 | 100 |
494-
class-2.js | 73.91 | 85.71 | 60 | 73.91 | 7-8,15-16,21-22
504+
class-2.js | 73.91 | 83.33 | 60 | 73.91 | 7-8,15-16,21-22
495505
------------|---------|----------|---------|---------|-------------------
496506
,"
497507
`;

0 commit comments

Comments
 (0)