From 40311b63373021116cc8cb9d1967276e613c5b82 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 16 Nov 2015 21:42:47 -0800 Subject: [PATCH] test: fix flaky test-child-process-spawnsync-input Move portion of `test-child-process-spawnsync-input.js` (that has been flaky on CentOS in CI) to its own file. This allows us to more easily eliminate the cause of the flakiness without affecting other unrelated portions of the test. Fixes: https://github.com/nodejs/node/issues/3863 PR-URL: https://github.com/nodejs/node/pull/3889 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- .../test-child-process-spawnsync-input.js | 12 --------- .../test-child-process-spawnsync-maxbuf.js | 27 +++++++++++++++++++ 2 files changed, 27 insertions(+), 12 deletions(-) create mode 100644 test/parallel/test-child-process-spawnsync-maxbuf.js diff --git a/test/parallel/test-child-process-spawnsync-input.js b/test/parallel/test-child-process-spawnsync-input.js index d978bd80bc81cd..338b4277fb1982 100644 --- a/test/parallel/test-child-process-spawnsync-input.js +++ b/test/parallel/test-child-process-spawnsync-input.js @@ -87,15 +87,3 @@ ret = spawnSync(process.execPath, args, { encoding: 'utf8' }); checkSpawnSyncRet(ret); assert.strictEqual(ret.stdout, msgOut + '\n'); assert.strictEqual(ret.stderr, msgErr + '\n'); - -options = { - maxBuffer: 1 -}; - -ret = spawnSync(process.execPath, args, options); - -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.deepEqual(ret.stdout, msgOutBuf); diff --git a/test/parallel/test-child-process-spawnsync-maxbuf.js b/test/parallel/test-child-process-spawnsync-maxbuf.js new file mode 100644 index 00000000000000..d8f286d7e01626 --- /dev/null +++ b/test/parallel/test-child-process-spawnsync-maxbuf.js @@ -0,0 +1,27 @@ +'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? +const msgOutBuf = new Buffer(msgOut + '\n'); + +const args = [ + '-e', + `console.log("${msgOut}");` +]; + +const options = { + maxBuffer: 1 +}; + +const ret = spawnSync(process.execPath, args, options); + +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.deepEqual(ret.stdout, msgOutBuf);