-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
test: add test for broken child process stdio #9528
Conversation
const ChildProcess = require('internal/child_process').ChildProcess; | ||
const original = ChildProcess.prototype.spawn; | ||
|
||
ChildProcess.prototype.spawn = function () { |
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'm seeing a jslint error on this line:
18:40 error Unexpected space before function parentheses space-before-function-paren
@danbev sorry. Fixed. |
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.
LGTM although I have a question
const cp = require('child_process'); | ||
|
||
if (process.argv[2] === 'child') { | ||
setTimeout(() => {}, common.platformTimeout(1000)); |
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 test works reliably for me (and runs faster) with the setTimeout()
replaced with a setImmediate()
. Are we sure that the timer is needed here? If so, any chance we can bring it down to 100ms instead of 1000ms?
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.
A setImmediate()
is likely a safe. I just wanted to make sure that the spawned process didn't complete before the 1ms timeout in the third scenario.
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.
LGTM
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.
LGTM, I like that the code coverage data is already being used in order to improve coverage :)
CI to validate across platforms: https://ci.nodejs.org/job/node-test-pull-request/4819/ |
CI again without the |
The latest CI run failed on AIX due to the child process exiting too quickly, and hence not being killed. Adding the timeout back, and setting the delay to 100, as requested in #9528 (comment). |
This commit adds a test for the scenario where a child process is spawned, but the stdio streams could not be created. PR-URL: nodejs#9528 Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
This commit adds a test for the scenario where a child process is spawned, but the stdio streams could not be created. PR-URL: #9528 Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
This commit adds a test for the scenario where a child process is spawned, but the stdio streams could not be created. PR-URL: nodejs#9528 Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
This commit adds a test for the scenario where a child process is spawned, but the stdio streams could not be created. PR-URL: #9528 Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
This commit adds a test for the scenario where a child process is spawned, but the stdio streams could not be created. PR-URL: #9528 Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
This commit adds a test for the scenario where a child process is spawned, but the stdio streams could not be created. PR-URL: #9528 Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Checklist
make -j8 test
(UNIX), orvcbuild test nosign
(Windows) passesAffected core subsystem(s)
test
Description of change
This commit adds a test for the scenario where a child process is spawned, but the stdio streams could not be created.
If you look at child process coverage, this adds coverage for the
else
conditions on lines 224, 227, 234, 237, 256, and 275.