Regression: Linux: (edge case) nyc returns 0% coverage if Node.js binary has permissions to bind to ports < 1024 via setcap
See original GitHub issueTo reproduce
- Install the simple test app.
git clone https://github.com/aral/simple-demonstration-of-nyc-bug-1281 bug-1281 cd bug-1281 npm i
- Ensure Node.js does not have permissions to access privileged ports:
sudo setcap 'cap_net_bind_service=-ep' `which node`
npm run coverage
succeeds (100%)- Get permissions for Node to bind to ports < 1024:
sudo setcap 'cap_net_bind_service=+ep' `which node`
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.
<strike>To reproduce
- Check out the git repo at https://source.ind.ie/site.js/app (branch: hugo)
- Run
./install
- Run
npm run coverage
What happens (nyc version 15.0.0)
Incorrectly reports 0% coverage:
> @small-tech/site.js@12.11.0 coverage /home/aral/small-tech/site.js/app
> QUIET=true nyc tape test/*.js | tap-nyc
----------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------|---------|----------|---------|---------|-------------------
All files | 0 | 0 | 0 | 0 |
----------|---------|----------|---------|---------|-------------------
total: 143
passing: 143
duration: 680ms
What happens (nyc version 14.1.1)
Works correctly:
> @small-tech/site.js@12.11.0 coverage /home/aral/small-tech/site.js/app
> QUIET=true nyc tape test/*.js | tap-nyc
-----------------------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
-----------------------|----------|----------|----------|----------|-------------------|
All files | 36.68 | 24.61 | 36.76 | 37.5 | |
app | 56.76 | 39.44 | 63.08 | 58.5 | |
index.js | 56.76 | 39.44 | 63.08 | 58.5 |... 97,898,899,900 |
app/bin/commands | 12.24 | 0 | 0 | 12.24 | |
serve.js | 12.24 | 0 | 0 | 12.24 |... 50,353,357,359 |
app/bin/lib | 15.69 | 12.5 | 5.13 | 15.67 | |
RsyncWatcher.js | 7.69 | 0 | 0 | 7.95 |... 91,192,193,195 |
cli.js | 100 | 100 | 100 | 100 | |
console-timestamp.js | 14.29 | 100 | 0 | 14.29 | 4,5,9,10,11,12 |
ensure.js | 8.79 | 0 | 0 | 8.99 |... 97,199,202,203 |
runtime.js | 100 | 75 | 100 | 100 | 16 |
status.js | 14.29 | 0 | 0 | 14.29 |... 35,36,37,39,42 |
sync.js | 9.8 | 0 | 0 | 9.8 |... 15,119,120,126 |
app/lib | 53.23 | 44.44 | 38.89 | 57.89 | |
Stats.js | 50 | 44 | 35.29 | 54.72 |... 18,120,122,124 |
clr.js | 100 | 50 | 100 | 100 | 6 |
errors.js | 100 | 100 | 100 | 100 | |
-----------------------|----------|----------|----------|----------|-------------------|
total: 143
passing: 143
duration: 1.7s
Environment Information
System:
OS: Linux 5.3 Pop!_OS 19.10
CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
Memory: 1.15 GB / 15.35 GB
Binaries:
Node: 12.14.1 - ~/.nvm/versions/node/v12.14.1/bin/node
Yarn: 1.21.1 - /usr/bin/yarn
npm: 6.13.7 - ~/.nvm/versions/node/v12.14.1/bin/npm
npmPackages:
nyc: ^14.1.1 => 14.1.1
</strike>Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:16 (6 by maintainers)
Top Results From Across the Web
code coverage with nyc returning 0% for lines, statement and ...
I'm using nodeJS and have created unit tests using sinon,chai along with code coverage nyc. but nyc is returning 0% for statements, lines, ......
Read more >Proceedings of the Linux Symposium - Rob Landley
The hook function should return zero if permission to execute the system call is granted. If zero is returned, the system call handler ......
Read more >Amber20.pdf - Amber Molecular Dynamics
Cover illustration: representation of cytochrome c3 being studied using simulations at constant pH and constant redox potential in Amber, using methodology ...
Read more >Untitled
17: There is a memory leak when `read -e' is used to read a line using readline. ... remove-bad-symbol-use.patch - Install binaries with...
Read more >Untitled
Smac deals pet express! Dr tina thomas washington il! American bulldog mix puppies, Don ringler toyota belton tx? 2007 civic si rear diffuser?...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
@ljharb Thank you very much for your input.
No, I get
tape
^4.9.0
throughstylelint-test-rule-tape
https://github.com/stylelint/stylelint-test-rule-tape/blob/6279a6512269720e737aa06490a6bf8f4d27fa31/package.json#L26