From c664109c721814b5125daa1b9c8aca4ea8763f88 Mon Sep 17 00:00:00 2001 From: Wietse Venema Date: Sat, 17 Sep 2016 10:40:10 +0200 Subject: [PATCH] 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 Reviewed-By: Santiago Gimeno Reviewed-By: James M Snell Reviewed-By: Ilkka Myller Reviewed-By: Prince John Wesley Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig Reviewed-By: Robert Jefe Lindstaedt --- .../test-child-process-stdout-flush.js | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/test/parallel/test-child-process-stdout-flush.js b/test/parallel/test-child-process-stdout-flush.js index 8300f4bbc7cbf3..cec3ccdebfb4d5 100644 --- a/test/parallel/test-child-process-stdout-flush.js +++ b/test/parallel/test-child-process-stdout-flush.js @@ -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); +}));