node/test/parallel/test-child-process-maxBuffer-stderr.js
Rich Trott c9a5990a76 child_process: measure buffer length in bytes
This change fixes a known issue where `maxBuffer` limits by characters
rather than bytes. Benchmark added to confirm no performance regression
occurs with this change.

PR-URL: https://github.com/nodejs/node/pull/6764
Fixes: https://github.com/nodejs/node/issues/1901
Reviewed-By: Brian White <mscdex@mscdex.net>
2016-05-25 10:57:59 -07:00

16 lines
465 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const cp = require('child_process');
const unicode = '中文测试'; // Length = 4, Byte length = 13
if (process.argv[2] === 'child') {
console.error(unicode);
} else {
const cmd = `${process.execPath} ${__filename} child`;
cp.exec(cmd, {maxBuffer: 10}, common.mustCall((err, stdout, stderr) => {
assert.strictEqual(err.message, 'stderr maxBuffer exceeded');
}));
}