2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2018-01-02 13:12:41 +01:00
|
|
|
// Tests that a spawned child process can write to stdout without throwing.
|
|
|
|
// See https://github.com/nodejs/node-v0.x-archive/issues/1899.
|
|
|
|
|
2017-10-06 11:17:55 -07:00
|
|
|
require('../common');
|
|
|
|
const fixtures = require('../common/fixtures');
|
2016-12-30 18:38:06 -05:00
|
|
|
const assert = require('assert');
|
|
|
|
const spawn = require('child_process').spawn;
|
2011-10-22 00:32:12 +02:00
|
|
|
|
2017-01-08 13:19:00 +00:00
|
|
|
const child = spawn(process.argv[0], [
|
2021-03-26 08:51:08 -07:00
|
|
|
fixtures.path('GH-1899-output.js'),
|
2012-01-17 19:43:34 +01:00
|
|
|
]);
|
2017-01-08 13:19:00 +00:00
|
|
|
let output = '';
|
2011-10-22 00:32:12 +02:00
|
|
|
|
2012-01-17 19:43:34 +01:00
|
|
|
child.stdout.on('data', function(data) {
|
2011-10-22 00:32:12 +02:00
|
|
|
output += data;
|
|
|
|
});
|
|
|
|
|
2012-01-17 19:43:34 +01:00
|
|
|
child.on('exit', function(code, signal) {
|
2017-01-08 15:36:25 +00:00
|
|
|
assert.strictEqual(code, 0);
|
|
|
|
assert.strictEqual(output, 'hello, world!\n');
|
2011-10-22 00:32:12 +02:00
|
|
|
});
|