From e0fa30fc515f7d6fa3f92193153d4e01863b37e2 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Sun, 9 Jun 2019 21:11:56 +0800 Subject: [PATCH] test: remove duplicate test-child-process-execfilesync-maxBuffer.js In addition correct the comment about what it does. PR-URL: https://github.com/nodejs/node/pull/28139 Reviewed-By: Yongsheng Zhang Reviewed-By: Anna Henningsen Reviewed-By: Luigi Pinca Reviewed-By: Rich Trott Reviewed-By: Colin Ihrig --- ...st-child-process-execfilesync-maxBuffer.js | 50 ------------------- .../test-child-process-execfilesync-maxbuf.js | 48 +++++++++--------- 2 files changed, 23 insertions(+), 75 deletions(-) delete mode 100644 test/parallel/test-child-process-execfilesync-maxBuffer.js diff --git a/test/parallel/test-child-process-execfilesync-maxBuffer.js b/test/parallel/test-child-process-execfilesync-maxBuffer.js deleted file mode 100644 index d4bed07d06030a..00000000000000 --- a/test/parallel/test-child-process-execfilesync-maxBuffer.js +++ /dev/null @@ -1,50 +0,0 @@ -'use strict'; -require('../common'); - -// This test checks that the maxBuffer option for child_process.spawnFileSync() -// works as expected. - -const assert = require('assert'); -const { execFileSync } = require('child_process'); -const msgOut = 'this is stdout'; -const msgOutBuf = Buffer.from(`${msgOut}\n`); - -const args = [ - '-e', - `console.log("${msgOut}");` -]; - -// Verify that an error is returned if maxBuffer is surpassed. -{ - assert.throws(() => { - execFileSync(process.execPath, args, { maxBuffer: 1 }); - }, (e) => { - assert.ok(e, 'maxBuffer should error'); - assert.strictEqual(e.errno, 'ENOBUFS'); - // We can have buffers larger than maxBuffer because underneath we alloc 64k - // that matches our read sizes. - assert.deepStrictEqual(e.stdout, msgOutBuf); - return true; - }); -} - -// Verify that a maxBuffer size of Infinity works. -{ - const ret = execFileSync(process.execPath, args, { maxBuffer: Infinity }); - - assert.deepStrictEqual(ret, msgOutBuf); -} - -// Default maxBuffer size is 1024 * 1024. -{ - assert.throws(() => { - execFileSync( - process.execPath, - ['-e', "console.log('a'.repeat(1024 * 1024))"] - ); - }, (e) => { - assert.ok(e, 'maxBuffer should error'); - assert.strictEqual(e.errno, 'ENOBUFS'); - return true; - }); -} diff --git a/test/parallel/test-child-process-execfilesync-maxbuf.js b/test/parallel/test-child-process-execfilesync-maxbuf.js index 2ec0489358b5ed..6e89444f3dac72 100644 --- a/test/parallel/test-child-process-execfilesync-maxbuf.js +++ b/test/parallel/test-child-process-execfilesync-maxbuf.js @@ -1,11 +1,11 @@ 'use strict'; require('../common'); -// This test checks that the maxBuffer option for child_process.spawnSync() +// This test checks that the maxBuffer option for child_process.execFileSync() // works as expected. const assert = require('assert'); -const execFileSync = require('child_process').execFileSync; +const { execFileSync } = require('child_process'); const msgOut = 'this is stdout'; const msgOutBuf = Buffer.from(`${msgOut}\n`); @@ -16,15 +16,16 @@ const args = [ // Verify that an error is returned if maxBuffer is surpassed. { - assert.throws( - () => execFileSync(process.execPath, args, { maxBuffer: 1 }), - (e) => { - assert.ok(e, 'maxBuffer should error'); - assert.strictEqual(e.errno, 'ENOBUFS'); - assert.deepStrictEqual(e.stdout, msgOutBuf); - return true; - } - ); + assert.throws(() => { + execFileSync(process.execPath, args, { maxBuffer: 1 }); + }, (e) => { + assert.ok(e, 'maxBuffer should error'); + assert.strictEqual(e.errno, 'ENOBUFS'); + // We can have buffers larger than maxBuffer because underneath we alloc 64k + // that matches our read sizes. + assert.deepStrictEqual(e.stdout, msgOutBuf); + return true; + }); } // Verify that a maxBuffer size of Infinity works. @@ -34,19 +35,16 @@ const args = [ assert.deepStrictEqual(ret, msgOutBuf); } -// maxBuffer size is 1024 * 1024 at default. +// Default maxBuffer size is 1024 * 1024. { - assert.throws( - () => { - execFileSync( - process.execPath, - ['-e', "console.log('a'.repeat(1024 * 1024))"], - { encoding: 'utf-8' } - ); - }, (e) => { - assert.ok(e, 'maxBuffer should error'); - assert.strictEqual(e.errno, 'ENOBUFS'); - return true; - } - ); + assert.throws(() => { + execFileSync( + process.execPath, + ['-e', "console.log('a'.repeat(1024 * 1024))"] + ); + }, (e) => { + assert.ok(e, 'maxBuffer should error'); + assert.strictEqual(e.errno, 'ENOBUFS'); + return true; + }); }