summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2016-05-14 15:24:34 -0700
committerRich Trott <rtrott@gmail.com>2016-05-25 10:57:59 -0700
commitc9a5990a76ccb15872234948e23bdc12691c2e70 (patch)
tree860e28d73ed7df27216938b3c7a808f74a45eb6b /test
parent33c7b45378777ddff6dad1a74095d0d8d155f56d (diff)
downloadandroid-node-v8-c9a5990a76ccb15872234948e23bdc12691c2e70.tar.gz
android-node-v8-c9a5990a76ccb15872234948e23bdc12691c2e70.tar.bz2
android-node-v8-c9a5990a76ccb15872234948e23bdc12691c2e70.zip
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>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-child-process-maxBuffer-stderr.js15
-rw-r--r--test/parallel/test-child-process-maxBuffer-stdout.js (renamed from test/known_issues/test-child-process-max-buffer.js)3
2 files changed, 16 insertions, 2 deletions
diff --git a/test/parallel/test-child-process-maxBuffer-stderr.js b/test/parallel/test-child-process-maxBuffer-stderr.js
new file mode 100644
index 0000000000..ecaea8b152
--- /dev/null
+++ b/test/parallel/test-child-process-maxBuffer-stderr.js
@@ -0,0 +1,15 @@
+'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');
+ }));
+}
diff --git a/test/known_issues/test-child-process-max-buffer.js b/test/parallel/test-child-process-maxBuffer-stdout.js
index 14a344c706..122dc499f4 100644
--- a/test/known_issues/test-child-process-max-buffer.js
+++ b/test/parallel/test-child-process-maxBuffer-stdout.js
@@ -1,5 +1,4 @@
'use strict';
-// Refs: https://github.com/nodejs/node/issues/1901
const common = require('../common');
const assert = require('assert');
const cp = require('child_process');
@@ -10,7 +9,7 @@ if (process.argv[2] === 'child') {
} else {
const cmd = `${process.execPath} ${__filename} child`;
- cp.exec(cmd, { maxBuffer: 10 }, common.mustCall((err, stdout, stderr) => {
+ cp.exec(cmd, {maxBuffer: 10}, common.mustCall((err, stdout, stderr) => {
assert.strictEqual(err.message, 'stdout maxBuffer exceeded');
}));
}