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
2010-07-15 14:21:31 -07:00

29 lines
646 B
JavaScript

common = require("../common");
assert = common.assert
var path = require('path');
var spawn = require('child_process').spawn;
var sub = path.join(common.fixturesDir, 'print-chars.js');
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);
assert.ok(false);
});
child.stderr.setEncoding('utf8');
child.stdout.addListener("data", function (data) {
count += data.length;
console.log(count);
});
child.addListener("exit", function (data) {
assert.equal(n, count);
console.log("okay");
});