test: improve test-child-process-stdout-flush
Changed vars to const / let, functions to arrow functions and a mustCall where appropriate. PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
parent
2b5acda7a2
commit
57a5136e96
@ -1,29 +1,26 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common');
|
const common = require('../common');
|
||||||
var assert = require('assert');
|
const assert = require('assert');
|
||||||
var path = require('path');
|
const path = require('path');
|
||||||
var spawn = require('child_process').spawn;
|
const spawn = require('child_process').spawn;
|
||||||
var sub = path.join(common.fixturesDir, 'print-chars.js');
|
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.setEncoding('utf8');
|
||||||
child.stderr.on('data', function(data) {
|
child.stderr.on('data', common.fail);
|
||||||
console.log('parent stderr: ' + data);
|
|
||||||
assert.ok(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
child.stdout.setEncoding('utf8');
|
child.stdout.setEncoding('utf8');
|
||||||
child.stdout.on('data', function(data) {
|
child.stdout.on('data', (data) => {
|
||||||
count += data.length;
|
count += data.length;
|
||||||
console.log(count);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
child.on('close', function(data) {
|
child.on('close', common.mustCall((code, signal) => {
|
||||||
assert.equal(n, count);
|
assert.strictEqual(code, 0);
|
||||||
console.log('okay');
|
assert.strictEqual(signal, null);
|
||||||
});
|
assert.strictEqual(n, count);
|
||||||
|
}));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user