summaryrefslogtreecommitdiff
path: root/test/parallel/test-child-process-stdout-flush.js
blob: 8300f4bbc7cbf377ec10b80be91018bb8b5016b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');
var spawn = require('child_process').spawn;
var sub = path.join(common.fixturesDir, 'print-chars.js');

var n = 500000;

var child = spawn(process.argv[0], [sub, n]);

var count = 0;

child.stderr.setEncoding('utf8');
child.stderr.on('data', function(data) {
  console.log('parent stderr: ' + data);
  assert.ok(false);
});

child.stdout.setEncoding('utf8');
child.stdout.on('data', function(data) {
  count += data.length;
  console.log(count);
});

child.on('close', function(data) {
  assert.equal(n, count);
  console.log('okay');
});