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