summaryrefslogtreecommitdiff
path: root/test/parallel/test-child-process-execfilesync-maxbuf.js
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2019-06-09 21:11:56 +0800
committerJoyee Cheung <joyeec9h3@gmail.com>2019-06-12 16:50:34 +0800
commite0fa30fc515f7d6fa3f92193153d4e01863b37e2 (patch)
tree0fc807df0e03d03bae7f487cb01b7d489bea3f65 /test/parallel/test-child-process-execfilesync-maxbuf.js
parent1f143b8625c2985b4317a40f279232f562417077 (diff)
downloadnode-new-e0fa30fc515f7d6fa3f92193153d4e01863b37e2.tar.gz
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 <zyszys98@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'test/parallel/test-child-process-execfilesync-maxbuf.js')
-rw-r--r--test/parallel/test-child-process-execfilesync-maxbuf.js48
1 files changed, 23 insertions, 25 deletions
diff --git a/test/parallel/test-child-process-execfilesync-maxbuf.js b/test/parallel/test-child-process-execfilesync-maxbuf.js
index 2ec0489358..6e89444f3d 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;
+ });
}