-
-
Notifications
You must be signed in to change notification settings - Fork 359
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
Regression: Linux: (edge case) nyc returns 0% coverage if Node.js binary has permissions to bind to ports < 1024 via setcap #1281
Comments
I have a similar issue, but with both versions of
|
Have you compared tape v4 vs tape v5? |
@ljharb No, I get |
In that case it’s unlikely to be a regression in tape itself; please let me know if there’s anything actionable on tape’s side. |
Alright. My updated {
"require": [
"babel-register"
],
"all": true,
"exclude": ["node_modules", "**/coverage/**", "commitlint.config.js", "test", "lint-staged.config.js"],
"include": ["src/**/*"],
"check-coverage": true,
"per-file": true,
"branches": 85,
"lines": 85,
"functions": 85,
"statements": 85
} According to the docs I think those issues maybe be related: |
Alright downgrading |
@AndyOGo OP does not appear to be directly using babel or esm and they did not experience the issue with nyc 14.1.1 so your issue seems unrelated. Please do not comment on existing issues when you have a similar issue, create a new issue. @aral sorry I haven't had a chance to dig deep into your issue yet. By chance would you be able to create a simplified branch? In particular a demonstration using less (or even no) extra dependencies beyond tape and nyc would be useful, as well not using a custom As for tape + nyc 15 I know for sure of projects successfully using this combination, I use them in node-preload for example. Additional note: I just noticed an active PR to upgrade |
Thanks for your answer @coreyfarrell Anyway I switched to |
@coreyfarrell Sorry it’s taken me so long to get back to you. Here’s the simplest possible demonstration of the bug: git clone /~https://github.com/aral/simple-demonstration-of-nyc-bug-1281 bug-1281
cd bug-1281
npm i
npm run coverage What should happenCoverage should be 100%. What actually happensCoverage is 0%. Further details (by version)
The codepackage.json (relevant bits)…
"scripts": {
"test": "tape test/*.js",
"coverage": "nyc tape test/*.js"
},
…
"dependencies": {
"nyc": "^15.0.1",
"tape": "^5.0.0"
} index.js (file being tested)module.exports = function () {
return true
} test/index.js (tape tests)const app = require('..')
const test = require('tape')
test('app',t => {
t.ok(app())
t.end()
}) |
I see 100% coverage when I run the demo repository you just posted. Tested with node.js 8, 10, 12 and 14 under Fedora 30 x86_64. |
@coreyfarrell Right, I just tested on a Mac and a PC (running Node v12.16.2) and I got 100% coverage also. Tried it on my main So it’s a (I’m running Pop!_OS 20.04; based on Ubuntu 20.04.) Update: Actually read your response properly and saw that you were running it under Fedora. So it’s a Debian/Ubuntu/Pop!_OS issue? |
I have no idea, this issue does not make sense. You are using |
@coreyfarrell Agree, it doesn’t :) I’m using Just tried:
So it’s definitely either something that is unique to my system or to Pop!_OS 20.04. Now that I’ve narrowed it down to that, will continue to look into it and let you know if I find anything. |
@coreyfarrell Wow, I figured out what it is… talk about a niche case: nyc returns 0% coverage if the Node.js binary has permissions to bind to ports < 1024 on Linux via To reproduce (with the simple example)
Run the first command again to return to being able to use nyc properly. It appears that using Thanks again for your time. |
This looks to be a node.js behavior intentionally implemented for security reasons, apparently any Thanks for following-up on this issue, I'm closing this as I don't believe any further action is needed from nyc. |
In case anyone else comes across this, one workaround is to disable privileged ports on Linux. Privileged ports made sense in the 1970s but they don’t in 2020. The option to remove them or to reduce the number was added in version 4.11 of the Linux kernel. I outline what I’ll be doing in the next version of Site.js here: |
To reproduce
git clone /~https://github.com/aral/simple-demonstration-of-nyc-bug-1281 bug-1281 cd bug-1281 npm i
npm run coverage
succeeds (100%)npm run coverage
fails (0%)Run the second step again to return to being able to use nyc properly.
It appears that using
setcap
to set permissions has side-effects. e.g., see this: Linux capabilities (setcap) seems to disable LD_LIBRARY_PATH.What should happen
Coverage should be 100% at Step 5.
What actually happens
Coverage is 0% at Step 5.
Regression
Works with nyc@14.1.1 (with both Tape 4.11.0 and Tape 5.0.0). The issue occurs on nyc@15.0.1.
To reproduce
./install
npm run coverage
What happens (nyc version 15.0.0)
Incorrectly reports 0% coverage:
What happens (nyc version 14.1.1)
Works correctly:
Environment Information
The text was updated successfully, but these errors were encountered: