Skip to content

Commit d633ba0

Browse files
juanarbolBethGriggs
authored andcommitted
test: improve test coverage in child_process
PR-URL: #26282 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Yongsheng Zhang <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 8dc4e4e commit d633ba0

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

‎test/parallel/test-child-process-validate-stdio.js‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@ const common = require('../common');
55
constassert=require('assert');
66
constgetValidStdio=require('internal/child_process').getValidStdio;
77

8-
constexpectedError=
9-
common.expectsError({code: 'ERR_INVALID_OPT_VALUE',type: TypeError},2);
8+
constexpectedError={code: 'ERR_INVALID_OPT_VALUE',type: TypeError};
109

1110
// Should throw if string and not ignore, pipe, or inherit
12-
assert.throws(()=>getValidStdio('foo'),expectedError);
11+
common.expectsError(()=>getValidStdio('foo'),expectedError);
1312

1413
// Should throw if not a string or array
15-
assert.throws(()=>getValidStdio(600),expectedError);
14+
common.expectsError(()=>getValidStdio(600),expectedError);
1615

1716
// Should populate stdio with undefined if len < 3
1817
{
@@ -30,6 +29,19 @@ common.expectsError(() => getValidStdio(stdio2, true),
3029
{code: 'ERR_IPC_SYNC_FORK',type: Error}
3130
);
3231

32+
// Should throw if stdio is not a valid input
33+
{
34+
conststdio=['foo'];
35+
common.expectsError(()=>getValidStdio(stdio,false),
36+
{code: 'ERR_INVALID_SYNC_FORK_INPUT',type: TypeError}
37+
);
38+
}
39+
40+
// Should throw if stdio is not a valid option
41+
{
42+
conststdio=[{foo: 'bar'}];
43+
common.expectsError(()=>getValidStdio(stdio),expectedError);
44+
}
3345

3446
if(common.isMainThread){
3547
conststdio3=[process.stdin,process.stdout,process.stderr];

0 commit comments

Comments
(0)