Skip to content
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

Merged
merged 1 commit into from
Nov 15, 2016
Merged

Conversation

cjihrig
Copy link
Contributor

@cjihrig cjihrig commented Nov 9, 2016

Checklist
  • make -j8 test (UNIX), or vcbuild test nosign (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected 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.

@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label Nov 9, 2016
const ChildProcess = require('internal/child_process').ChildProcess;
const original = ChildProcess.prototype.spawn;

ChildProcess.prototype.spawn = function () {
Copy link
Contributor

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

@cjihrig
Copy link
Contributor Author

cjihrig commented Nov 9, 2016

@danbev sorry. Fixed.

@mscdex mscdex added the child_process Issues and PRs related to the child_process subsystem. label Nov 9, 2016
Copy link
Member

@Trott Trott left a 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));
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

@santigimeno santigimeno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@mhdawson mhdawson left a 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 :)

@mhdawson
Copy link
Member

CI to validate across platforms: https://ci.nodejs.org/job/node-test-pull-request/4819/

@cjihrig
Copy link
Contributor Author

cjihrig commented Nov 15, 2016

CI again without the setTimeout() - https://ci.nodejs.org/job/node-test-pull-request/4848/

@cjihrig
Copy link
Contributor Author

cjihrig commented Nov 15, 2016

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).

@cjihrig
Copy link
Contributor Author

cjihrig commented Nov 15, 2016

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>
@cjihrig cjihrig merged commit 7cdfe8a into nodejs:master Nov 15, 2016
@cjihrig cjihrig deleted the stdio branch November 15, 2016 20:39
Fishrock123 pushed a commit that referenced this pull request Nov 22, 2016
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>
addaleax pushed a commit to addaleax/node that referenced this pull request Dec 8, 2016
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>
MylesBorins pushed a commit that referenced this pull request Dec 20, 2016
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>
MylesBorins pushed a commit that referenced this pull request Dec 21, 2016
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>
MylesBorins pushed a commit that referenced this pull request Dec 21, 2016
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 was referenced Dec 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
child_process Issues and PRs related to the child_process subsystem. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants