Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: remove duplicate test-child-process-execfilesync-maxBuffer.js #28139

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 0 additions & 50 deletions test/parallel/test-child-process-execfilesync-maxBuffer.js

This file was deleted.

48 changes: 23 additions & 25 deletions test/parallel/test-child-process-execfilesync-maxbuf.js
Original file line number Diff line number Diff line change
@@ -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`);

Expand All @@ -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.
Expand All @@ -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;
});
}