0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/simple/test-child-process-stdout-flush.js

29 lines
646 B
JavaScript
Raw Normal View History

common = require("../common");
assert = common.assert
2010-03-17 22:00:17 +01:00
var path = require('path');
var spawn = require('child_process').spawn;
var sub = path.join(common.fixturesDir, 'print-chars.js');
2010-03-17 22:00:17 +01:00
n = 500000;
var child = spawn(process.argv[0], [sub, n]);
var count = 0;
child.stderr.setEncoding('utf8');
child.stderr.addListener("data", function (data) {
console.log("parent stderr: " + data);
2010-03-17 22:00:17 +01:00
assert.ok(false);
});
child.stderr.setEncoding('utf8');
child.stdout.addListener("data", function (data) {
count += data.length;
console.log(count);
2010-03-17 22:00:17 +01:00
});
child.addListener("exit", function (data) {
assert.equal(n, count);
console.log("okay");
2010-03-17 22:00:17 +01:00
});