summaryrefslogtreecommitdiff
path: root/test/parallel/test-stdout-buffer-flush-on-exit.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/parallel/test-stdout-buffer-flush-on-exit.js')
-rw-r--r--test/parallel/test-stdout-buffer-flush-on-exit.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/parallel/test-stdout-buffer-flush-on-exit.js b/test/parallel/test-stdout-buffer-flush-on-exit.js
new file mode 100644
index 0000000000..791a9ccd15
--- /dev/null
+++ b/test/parallel/test-stdout-buffer-flush-on-exit.js
@@ -0,0 +1,25 @@
+'use strict';
+// Refs: https://github.com/nodejs/node/issues/2148
+
+require('../common');
+const assert = require('assert');
+const execSync = require('child_process').execSync;
+
+const lineSeed = 'foo bar baz quux quuz aaa bbb ccc';
+
+if (process.argv[2] === 'child') {
+ const longLine = lineSeed.repeat(parseInt(process.argv[4], 10));
+ process.on('exit', () => {
+ console.log(longLine);
+ });
+ process.exit();
+}
+
+[22, 16].forEach((exponent) => {
+ const bigNum = Math.pow(2, exponent);
+ const longLine = lineSeed.repeat(bigNum);
+ const cmd = `${process.execPath} ${__filename} child ${exponent} ${bigNum}`;
+ const stdout = execSync(cmd).toString().trim();
+
+ assert.strictEqual(stdout, longLine, `failed with exponent ${exponent}`);
+});