Skip to content

Commit

Permalink
test: improve test-child-process-stdout-flush
Browse files Browse the repository at this point in the history
Changed vars to const / let, functions to arrow functions and a
mustCall where appropriate.

PR-URL: #8581
Reviewed-By: Robert Jefe Lindstaedt <robert.lindstaedt@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Robert Jefe Lindstaedt <robert.lindstaedt@gmail.com>
  • Loading branch information
Wietse Venema authored and jasnell committed Sep 20, 2016
1 parent 2b5acda commit 57a5136
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions test/parallel/test-child-process-stdout-flush.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
'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');
const common = require('../common');
const assert = require('assert');
const path = require('path');
const spawn = require('child_process').spawn;
const sub = path.join(common.fixturesDir, 'print-chars.js');

var n = 500000;
const n = 500000;

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

var count = 0;
let count = 0;

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

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

child.on('close', function(data) {
assert.equal(n, count);
console.log('okay');
});
child.on('close', common.mustCall((code, signal) => {
assert.strictEqual(code, 0);
assert.strictEqual(signal, null);
assert.strictEqual(n, count);
}));

0 comments on commit 57a5136

Please sign in to comment.