diff options
author | cjihrig <cjihrig@gmail.com> | 2017-01-16 13:17:34 -0500 |
---|---|---|
committer | cjihrig <cjihrig@gmail.com> | 2017-01-17 10:49:12 -0500 |
commit | 5b30c4f24da8039bcfbd9d453b74fdd986cb000e (patch) | |
tree | 9ff56854f0096172b501e18b284777b139e60952 /test/parallel/test-child-process-spawnsync-maxbuf.js | |
parent | 8f3ff98f0e59926e7de3de56497cef270918629b (diff) | |
download | android-node-v8-5b30c4f24da8039bcfbd9d453b74fdd986cb000e.tar.gz android-node-v8-5b30c4f24da8039bcfbd9d453b74fdd986cb000e.tar.bz2 android-node-v8-5b30c4f24da8039bcfbd9d453b74fdd986cb000e.zip |
test: refactor test-child-process-spawnsync-maxbuf
This commit refactors test-child-process-spawnsync-maxbuf.js,
and adds testing for the case where maxBuffer is Infinity.
PR-URL: https://github.com/nodejs/node/pull/10769
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/parallel/test-child-process-spawnsync-maxbuf.js')
-rw-r--r-- | test/parallel/test-child-process-spawnsync-maxbuf.js | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/test/parallel/test-child-process-spawnsync-maxbuf.js b/test/parallel/test-child-process-spawnsync-maxbuf.js index 87099737ec..d9c2c4d23e 100644 --- a/test/parallel/test-child-process-spawnsync-maxbuf.js +++ b/test/parallel/test-child-process-spawnsync-maxbuf.js @@ -1,9 +1,7 @@ 'use strict'; require('../common'); const assert = require('assert'); - const spawnSync = require('child_process').spawnSync; - const msgOut = 'this is stdout'; // This is actually not os.EOL? @@ -14,14 +12,21 @@ const args = [ `console.log("${msgOut}");` ]; -const options = { - maxBuffer: 1 -}; +// Verify that an error is returned if maxBuffer is surpassed. +{ + 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.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); + assert.ifError(ret.error); + assert.deepStrictEqual(ret.stdout, msgOutBuf); +} |