@ -1,9 +1,7 @@
'use strict' ;
'use strict' ;
require ( '../common' ) ;
require ( '../common' ) ;
const assert = require ( 'assert' ) ;
const assert = require ( 'assert' ) ;
const spawnSync = require ( 'child_process' ) . spawnSync ;
const spawnSync = require ( 'child_process' ) . spawnSync ;
const msgOut = 'this is stdout' ;
const msgOut = 'this is stdout' ;
// This is actually not os.EOL?
// This is actually not os.EOL?
@ -14,14 +12,21 @@ const args = [
` console.log(" ${ msgOut } "); `
` console.log(" ${ msgOut } "); `
] ;
] ;
const options = {
// Verify that an error is returned if maxBuffer is surpassed.
maxBuffer : 1
{
} ;
const ret = spawnSync ( process . execPath , args , { maxBuffer : 1 } ) ;
assert . ok ( ret . error , 'maxBuffer should error' ) ;
assert . strictEqual ( ret . error . errno , 'ENOBUFS' ) ;
// We can have buffers larger than maxBuffer because underneath we alloc 64k
// that matches our read sizes.
assert . deepStrictEqual ( ret . stdout , msgOutBuf ) ;
}
const ret = spawnSync ( process . execPath , args , options ) ;
// Verify that a maxBuffer size of Infinity works.
{
const ret = spawnSync ( process . execPath , args , { maxBuffer : Infinity } ) ;
assert . ok ( ret . error , 'maxBuffer should error' ) ;
assert . ifError ( ret . error ) ;
assert . strictEqual ( ret . error . errno , 'ENOBUFS' ) ;
assert . deepStrictEqual ( ret . stdout , msgOutBuf ) ;
// We can have buffers larger than maxBuffer because underneath we alloc 64k
}
// that matches our read sizes
assert . deepStrictEqual ( ret . stdout , msgOutBuf ) ;