2010-12-05 07:20:34 +08:00
|
|
|
var common = require('../common');
|
|
|
|
var assert = require('assert');
|
2010-03-18 05:00:17 +08:00
|
|
|
var path = require('path');
|
|
|
|
var spawn = require('child_process').spawn;
|
2010-07-16 02:47:25 +08:00
|
|
|
var sub = path.join(common.fixturesDir, 'print-chars.js');
|
2010-03-18 05:00:17 +08:00
|
|
|
|
2010-12-05 07:20:34 +08:00
|
|
|
var n = 500000;
|
2010-03-18 05:00:17 +08:00
|
|
|
|
|
|
|
var child = spawn(process.argv[0], [sub, n]);
|
|
|
|
|
|
|
|
var count = 0;
|
|
|
|
|
|
|
|
child.stderr.setEncoding('utf8');
|
|
|
|
child.stderr.addListener("data", function (data) {
|
2010-06-24 08:40:51 +08:00
|
|
|
console.log("parent stderr: " + data);
|
2010-03-18 05:00:17 +08:00
|
|
|
assert.ok(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
child.stderr.setEncoding('utf8');
|
|
|
|
child.stdout.addListener("data", function (data) {
|
|
|
|
count += data.length;
|
2010-06-24 08:40:51 +08:00
|
|
|
console.log(count);
|
2010-03-18 05:00:17 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
child.addListener("exit", function (data) {
|
|
|
|
assert.equal(n, count);
|
2010-06-24 08:40:51 +08:00
|
|
|
console.log("okay");
|
2010-03-18 05:00:17 +08:00
|
|
|
});
|