@ -2,8 +2,8 @@
// Flags: --expose_internals
require ( '../common' ) ;
var assert = require ( 'assert' ) ;
var _ validateStdio = require ( 'internal/child_process' ) . _ validateStdio ;
const assert = require ( 'assert' ) ;
const _ validateStdio = require ( 'internal/child_process' ) . _ validateStdio ;
// should throw if string and not ignore, pipe, or inherit
assert . throws ( function ( ) {
@ -16,27 +16,31 @@ assert.throws(function() {
} , /Incorrect value of stdio option/ ) ;
// should populate stdio with undefined if len < 3
var stdio1 = [ ] ;
var result = _ validateStdio ( stdio1 , false ) ;
assert . equal ( stdio1 . length , 3 ) ;
assert . equal ( result . hasOwnProperty ( 'stdio' ) , true ) ;
assert . equal ( result . hasOwnProperty ( 'ipc' ) , true ) ;
assert . equal ( result . hasOwnProperty ( 'ipcFd' ) , true ) ;
{
const stdio1 = [ ] ;
const result = _ validateStdio ( stdio1 , false ) ;
assert . equal ( stdio1 . length , 3 ) ;
assert . equal ( result . hasOwnProperty ( 'stdio' ) , true ) ;
assert . equal ( result . hasOwnProperty ( 'ipc' ) , true ) ;
assert . equal ( result . hasOwnProperty ( 'ipcFd' ) , true ) ;
}
// should throw if stdio has ipc and sync is true
var stdio2 = [ 'ipc' , 'ipc' , 'ipc' ] ;
const stdio2 = [ 'ipc' , 'ipc' , 'ipc' ] ;
assert . throws ( function ( ) {
_ validateStdio ( stdio2 , true ) ;
} , /You cannot use IPC with synchronous forks/ ) ;
const stdio3 = [ process . stdin , process . stdout , process . stderr ] ;
var result = _ validateStdio ( stdio3 , false ) ;
assert . deepStrictEqual ( result , {
stdio : [
{ type : 'fd' , fd : 0 } ,
{ type : 'fd' , fd : 1 } ,
{ type : 'fd' , fd : 2 }
] ,
ipc : undefined ,
ipcFd : undefined
} ) ;
{
const stdio3 = [ process . stdin , process . stdout , process . stderr ] ;
const result = _ validateStdio ( stdio3 , false ) ;
assert . deepStrictEqual ( result , {
stdio : [
{ type : 'fd' , fd : 0 } ,
{ type : 'fd' , fd : 1 } ,
{ type : 'fd' , fd : 2 }
] ,
ipc : undefined ,
ipcFd : undefined
} ) ;
}