https://github.com/boneskull/mocha-nyc-parallel-issue
testing a bug
https://github.com/boneskull/mocha-nyc-parallel-issue
Last synced: 6 months ago
JSON representation
testing a bug
- Host: GitHub
- URL: https://github.com/boneskull/mocha-nyc-parallel-issue
- Owner: boneskull
- Created: 2020-10-20T22:38:24.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-10-20T23:26:01.000Z (over 5 years ago)
- Last Synced: 2024-10-29T22:37:10.522Z (over 1 year ago)
- Language: JavaScript
- Size: 30.3 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
This repo shows a problem with `nyc` collecting coverage data from forked processes on Windows.
1. Run `npm install`
1. Run `npm test`, which will execute (with `nyc`):
1. `test/foo-fork.spec.js`; should return no coverage on Windows/PowerShell
1. `test/foo-workerpool.spec.js`; should return no coverage on Windows/PowerShell
1. `test/foo-spawn.spec.js`; should return coverage
1. `test/foo-fork-ok.spec.js`; should return coverage
`src/foo-fork-ok.js` shows the child process terminates itself.
I think we can conclude: on Windows, a subprocess opened via `child_process.fork()` _must terminate itself_ in order to gather coverage. Upon signal (e.g., `SIGINT`), a child process cannot execute any "cleanup" code; it cannot, e.g.:
```js
process.on("SIGINT", () => {
process.exit();
});
```
What should happen is that `workerpool` does not send a signal to a child process to terminate it; instead it will send a special message, and the child process will then terminate itself.