|
1 | 1 | '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'); |
7 | 7 |
|
8 |
| -var n = 500000; |
| 8 | +const n = 500000; |
9 | 9 |
|
10 |
| -var child = spawn(process.argv[0], [sub, n]); |
| 10 | +const child = spawn(process.argv[0], [sub, n]); |
11 | 11 |
|
12 |
| -var count = 0; |
| 12 | +let count = 0; |
13 | 13 |
|
14 | 14 | 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); |
19 | 16 |
|
20 | 17 | child.stdout.setEncoding('utf8');
|
21 |
| -child.stdout.on('data', function(data) { |
| 18 | +child.stdout.on('data', (data) => { |
22 | 19 | count += data.length;
|
23 |
| - console.log(count); |
24 | 20 | });
|
25 | 21 |
|
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