Skip to content

Commit e0fa30f

Browse files
committed
test: remove duplicate test-child-process-execfilesync-maxBuffer.js
In addition correct the comment about what it does. PR-URL: nodejs#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>
1 parent 1f143b8 commit e0fa30f

2 files changed

+23
-75
lines changed

test/parallel/test-child-process-execfilesync-maxBuffer.js

-50
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
'use strict';
22
require('../common');
33

4-
// This test checks that the maxBuffer option for child_process.spawnSync()
4+
// This test checks that the maxBuffer option for child_process.execFileSync()
55
// works as expected.
66

77
const assert = require('assert');
8-
const execFileSync = require('child_process').execFileSync;
8+
const { execFileSync } = require('child_process');
99
const msgOut = 'this is stdout';
1010
const msgOutBuf = Buffer.from(`${msgOut}\n`);
1111

@@ -16,15 +16,16 @@ const args = [
1616

1717
// Verify that an error is returned if maxBuffer is surpassed.
1818
{
19-
assert.throws(
20-
() => execFileSync(process.execPath, args, { maxBuffer: 1 }),
21-
(e) => {
22-
assert.ok(e, 'maxBuffer should error');
23-
assert.strictEqual(e.errno, 'ENOBUFS');
24-
assert.deepStrictEqual(e.stdout, msgOutBuf);
25-
return true;
26-
}
27-
);
19+
assert.throws(() => {
20+
execFileSync(process.execPath, args, { maxBuffer: 1 });
21+
}, (e) => {
22+
assert.ok(e, 'maxBuffer should error');
23+
assert.strictEqual(e.errno, 'ENOBUFS');
24+
// We can have buffers larger than maxBuffer because underneath we alloc 64k
25+
// that matches our read sizes.
26+
assert.deepStrictEqual(e.stdout, msgOutBuf);
27+
return true;
28+
});
2829
}
2930

3031
// Verify that a maxBuffer size of Infinity works.
@@ -34,19 +35,16 @@ const args = [
3435
assert.deepStrictEqual(ret, msgOutBuf);
3536
}
3637

37-
// maxBuffer size is 1024 * 1024 at default.
38+
// Default maxBuffer size is 1024 * 1024.
3839
{
39-
assert.throws(
40-
() => {
41-
execFileSync(
42-
process.execPath,
43-
['-e', "console.log('a'.repeat(1024 * 1024))"],
44-
{ encoding: 'utf-8' }
45-
);
46-
}, (e) => {
47-
assert.ok(e, 'maxBuffer should error');
48-
assert.strictEqual(e.errno, 'ENOBUFS');
49-
return true;
50-
}
51-
);
40+
assert.throws(() => {
41+
execFileSync(
42+
process.execPath,
43+
['-e', "console.log('a'.repeat(1024 * 1024))"]
44+
);
45+
}, (e) => {
46+
assert.ok(e, 'maxBuffer should error');
47+
assert.strictEqual(e.errno, 'ENOBUFS');
48+
return true;
49+
});
5250
}

0 commit comments

Comments
 (0)