0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-child-process-exec-maxBuffer.js
Beth Griggs 4f1eddf84e test: add missing console.error to exec-maxBuffer
Adds the missing console.error to test-child-process-exec-maxBuffer

PR-URL: https://github.com/nodejs/node/pull/14796
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: David Cai <davidcai1993@yahoo.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2017-08-16 11:31:21 +02:00

43 lines
1.0 KiB
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const cp = require('child_process');
function checkFactory(streamName) {
return common.mustCall((err) => {
const message = `${streamName} maxBuffer exceeded`;
assert.strictEqual(err.message, message);
});
}
{
const cmd = `"${process.execPath}" -e "console.log('hello world');"`;
const options = { maxBuffer: Infinity };
cp.exec(cmd, options, common.mustCall((err, stdout, stderr) => {
assert.ifError(err);
assert.strictEqual(stdout.trim(), 'hello world');
assert.strictEqual(stderr, '');
}));
}
{
const cmd = 'echo "hello world"';
cp.exec(cmd, { maxBuffer: 5 }, checkFactory('stdout'));
}
const unicode = '中文测试'; // length = 4, byte length = 12
{
const cmd = `"${process.execPath}" -e "console.log('${unicode}');"`;
cp.exec(cmd, { maxBuffer: 10 }, checkFactory('stdout'));
}
{
const cmd = `"${process.execPath}" -e "console.error('${unicode}');"`;
cp.exec(cmd, { maxBuffer: 10 }, checkFactory('stderr'));
}