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

c8 ignore next comment does not quite appropriately compensate for branches #254

Closed
Trott opened this issue Sep 25, 2020 · 6 comments · Fixed by #258 or #267
Closed

c8 ignore next comment does not quite appropriately compensate for branches #254

Trott opened this issue Sep 25, 2020 · 6 comments · Fixed by #258 or #267

Comments

@Trott
Copy link
Contributor

Trott commented Sep 25, 2020

  • Version: v14.12.0
  • Platform: macOS Darwin Kernel Version 19.6.0

Given this code in index.js:

function fn() {
  return true;
  /* c8 ignore next */
  console.log('never runs');
}

fn();

Running with ci node index.js, I get this output:

----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
----------|---------|----------|---------|---------|-------------------
All files |     100 |    66.67 |     100 |     100 |                   
 index.js |     100 |    66.67 |     100 |     100 | 2                 
----------|---------|----------|---------|---------|-------------------

I would expect the branches to all be considered covered since the entire uncovered branch is excluded by the c8 ignore comment.

----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
----------|---------|----------|---------|---------|-------------------
All files |     100 |    100 |     100 |     100 |                   
 index.js |     100 |    100 |     100 |     100 | 2                 
----------|---------|----------|---------|---------|-------------------
@Trott
Copy link
Contributor Author

Trott commented Sep 25, 2020

Even simpler reproduction:

return true;
/* c8 ignore next */
console.log('never runs');

@bcoe
Copy link
Owner

bcoe commented Oct 1, 2020

thanks @Trott 👍 will try to get to this in the not too distant future 🚀

@bcoe
Copy link
Owner

bcoe commented Oct 8, 2020

this should be fixed in c8@7.3.2.

@bcoe bcoe reopened this Oct 8, 2020
@bcoe
Copy link
Owner

bcoe commented Oct 8, 2020

unfortunately this caused a regression with TypeScript, tldr; source maps are the worst.

@Trott
Copy link
Contributor Author

Trott commented Oct 8, 2020

unfortunately this caused a regression with TypeScript, tldr; source maps are the worst.

NOOOOOOOOoooooooooooo,,,,....!!!!!

@bcoe
Copy link
Owner

bcoe commented Oct 16, 2020

@Trott wow, it too me this long to get to this message in my inbox 😆

I have a cunning plan, I was thinking we could perhaps check if the covered range is only 1 character, at which point I think it's a good indicator I've detected a \n character.

I'll play with this soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants