-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Remove debug
and inspect
flags from the arguments sent to the child
#5068
Conversation
168aa65
to
22c4e3f
Compare
Markdown changes are me running |
@@ -41,14 +43,19 @@ beforeEach(() => { | |||
|
|||
afterEach(() => { | |||
jest.resetModules(); | |||
// eslint-disable-next-line no-native-reassign | |||
process = properProcess; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like ideas here... require('process')
; and mock it properly?
}); | ||
|
||
it('passes fork options down to child_process.fork, adding the defaults', () => { | ||
const child = require.resolve('../child'); | ||
|
||
Object.assign(process, {execArgv: ['--inspect', '-p']}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find it funny that eslint does not yell at me for native-reassign
here
packages/jest-worker/src/worker.js
Outdated
@@ -80,6 +80,9 @@ export default class { | |||
{ | |||
cwd: process.cwd(), | |||
env: process.env, | |||
// suppress --debug / --inspect flags while preserving others (like --harmony) | |||
// inspired by https://github.com/rvagg/node-worker-farm/blob/f63d988c307a6805e03b1650f8ef0fb7ca6f1546/lib/fork.js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need the comment? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe not. It's a pure copy, though :P
}); | ||
|
||
it('passes fork options down to child_process.fork, adding the defaults', () => { | ||
const child = require.resolve('../child'); | ||
|
||
Object.assign(process, {execArgv: ['--inspect', '-p']}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The process
=> properProcess
dance does not prevent from modifying the global object, since Object.assign
will assign to the real process
. Instead you might want to save execArgv
at the beginning, and re-assign to process
on the afterEach
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really care that I modify it, it's sandboxed for this test in particular, right?
Good idea on just messing with the part I need to mess with, though
Codecov Report
@@ Coverage Diff @@
## master #5068 +/- ##
==========================================
+ Coverage 60.75% 60.76% +<.01%
==========================================
Files 198 198
Lines 6602 6603 +1
Branches 4 4
==========================================
+ Hits 4011 4012 +1
Misses 2591 2591
Continue to review full report at Codecov.
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
Using
jest-worker
when debugging caused it to crash. This ports over code from worker-farm which automatically filters away/--(debug|inspect)(-brk)?
. (https://github.com/rvagg/node-worker-farm/blob/f63d988c307a6805e03b1650f8ef0fb7ca6f1546/lib/fork.js#L8-L11)Test plan
Modified test to illustrate the filtering behaviour.