Skip to content

Commit c664109

Browse files
Wietse VenemaFishrock123
authored andcommitted
test: improve test-child-process-stdout-flush
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>
1 parent 7403aaa commit c664109

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed
Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,26 @@
11
'use strict';
2-
var common = require('../common');
3-
var assert = require('assert');
4-
var path = require('path');
5-
var spawn = require('child_process').spawn;
6-
var sub = path.join(common.fixturesDir, 'print-chars.js');
2+
const common = require('../common');
3+
const assert = require('assert');
4+
const path = require('path');
5+
const spawn = require('child_process').spawn;
6+
const sub = path.join(common.fixturesDir, 'print-chars.js');
77

8-
var n = 500000;
8+
const n = 500000;
99

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

12-
var count = 0;
12+
let count = 0;
1313

1414
child.stderr.setEncoding('utf8');
15-
child.stderr.on('data', function(data) {
16-
console.log('parent stderr: ' + data);
17-
assert.ok(false);
18-
});
15+
child.stderr.on('data', common.fail);
1916

2017
child.stdout.setEncoding('utf8');
21-
child.stdout.on('data', function(data) {
18+
child.stdout.on('data', (data) => {
2219
count += data.length;
23-
console.log(count);
2420
});
2521

26-
child.on('close', function(data) {
27-
assert.equal(n, count);
28-
console.log('okay');
29-
});
22+
child.on('close', common.mustCall((code, signal) => {
23+
assert.strictEqual(code, 0);
24+
assert.strictEqual(signal, null);
25+
assert.strictEqual(n, count);
26+
}));

0 commit comments

Comments
 (0)