Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
squash: revise tests
  • Loading branch information
Trott committed Jun 27, 2016
commit 381b0e60f461591cf2cbed81f56cda87b05da39d
35 changes: 20 additions & 15 deletions test/parallel/test-child-process-exec-maxBuffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,30 @@
const common = require('../common');
const assert = require('assert');
const cp = require('child_process');
const unicode = '中文测试'; // Length = 4, Byte length = 13

if (process.argv[2] === 'stdout') {
console.log(unicode);
return;
function checkFactory(streamName) {
return common.mustCall((err) => {
const message = `${streamName} maxBuffer exceeded`;
assert.strictEqual(err.message, message);
});
}

if (process.argv[2] === 'stderr') {
console.error(unicode);
return;
{
const cmd = 'echo "hello world"';

cp.exec(cmd, { maxBuffer: 5 }, checkFactory('stdout'));
}

const cmd = `${process.execPath} ${__filename}`;
const outputs = ['stdout', 'stderr'];
{
const unicode = '中文测试'; // Length = 4, Byte length = 12
const cmd = `echo ${unicode}`;

outputs.forEach((stream) => {
const cb = common.mustCall((err, stdout, stderr) => {
assert.strictEqual(err.message, `${stream} maxBuffer exceeded`);
});
cp.exec(cmd, {maxBuffer: 10}, checkFactory('stdout'));
}

{
const unicode = '中文测试'; // Length = 4, Byte length = 12
const cmd = `echo ${unicode} 1>&2`;

cp.exec(`${cmd} ${stream}`, {maxBuffer: 10}, cb);
});
cp.exec(cmd, {maxBuffer: 10}, checkFactory('stderr'));
}
11 changes: 0 additions & 11 deletions test/parallel/test-exec-max-buffer.js

This file was deleted.