-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
test: improve test coverage in child_process #26282
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,14 +5,13 @@ const common = require('../common'); | |
const assert = require('assert'); | ||
const getValidStdio = require('internal/child_process').getValidStdio; | ||
|
||
const expectedError = | ||
common.expectsError({ code: 'ERR_INVALID_OPT_VALUE', type: TypeError }, 2); | ||
const expectedError = { code: 'ERR_INVALID_OPT_VALUE', type: TypeError }; | ||
|
||
// Should throw if string and not ignore, pipe, or inherit | ||
assert.throws(() => getValidStdio('foo'), expectedError); | ||
common.expectsError(() => getValidStdio('foo'), expectedError); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please leave it as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I see, this just moves the expectsError, rather than introducing it. Never mind my comment. Should eventually be removed anyway but not necessarily in this PF and it probably needs to wait for Node.js 8 to EOL. |
||
|
||
// Should throw if not a string or array | ||
assert.throws(() => getValidStdio(600), expectedError); | ||
common.expectsError(() => getValidStdio(600), expectedError); | ||
|
||
// Should populate stdio with undefined if len < 3 | ||
{ | ||
|
@@ -30,6 +29,19 @@ common.expectsError(() => getValidStdio(stdio2, true), | |
{ code: 'ERR_IPC_SYNC_FORK', type: Error } | ||
); | ||
|
||
// Should throw if stdio is not a valid input | ||
{ | ||
const stdio = ['foo']; | ||
common.expectsError(() => getValidStdio(stdio, false), | ||
{ code: 'ERR_INVALID_SYNC_FORK_INPUT', type: TypeError } | ||
); | ||
} | ||
|
||
// Should throw if stdio is not a valid option | ||
{ | ||
const stdio = [{ foo: 'bar' }]; | ||
BridgeAR marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would be better if we can collect all invalid options which both throw Things like: ['foo', 600, [{ foo: 'bar' }]].forEach((stdio) => {
common.expectsError(() => _validateStdio(stdio), expectedError);
}) But it shouldn't block this :) |
||
common.expectsError(() => getValidStdio(stdio), expectedError); | ||
} | ||
|
||
if (common.isMainThread) { | ||
const stdio3 = [process.stdin, process.stdout, process.stderr]; | ||
|
Uh oh!
There was an error while loading. Please reload this page.