From 0f8a32354646775fb2c8a1a14cb807c7791e8034 Mon Sep 17 00:00:00 2001 From: Travis Bretton Date: Thu, 1 Dec 2016 09:53:01 -0700 Subject: [PATCH] test: cleanup test-stdout-close-catch.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added common.mustCall in child process on 'close' callback Changed several 'var' statements to 'const' or 'let' where appropriate Also linting PR-URL: https://github.com/nodejs/node/pull/10006 Reviewed-By: Michael Dawson Reviewed-By: Michaƫl Zasso Reviewed-By: Colin Ihrig Reviewed-By: Roman Reiss --- test/parallel/test-stdout-close-catch.js | 35 +++++++++++++----------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/test/parallel/test-stdout-close-catch.js b/test/parallel/test-stdout-close-catch.js index 15315fe82c6df5..2270fedd75f183 100644 --- a/test/parallel/test-stdout-close-catch.js +++ b/test/parallel/test-stdout-close-catch.js @@ -1,27 +1,30 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var path = require('path'); -var child_process = require('child_process'); +const common = require('../common'); +const assert = require('assert'); +const path = require('path'); +const child_process = require('child_process'); -var testScript = path.join(common.fixturesDir, 'catch-stdout-error.js'); +const testScript = path.join(common.fixturesDir, 'catch-stdout-error.js'); -var cmd = JSON.stringify(process.execPath) + ' ' + - JSON.stringify(testScript) + ' | ' + - JSON.stringify(process.execPath) + ' ' + - '-pe "process.stdin.on(\'data\' , () => process.exit(1))"'; +const cmd = JSON.stringify(process.execPath) + ' ' + + JSON.stringify(testScript) + ' | ' + + JSON.stringify(process.execPath) + ' ' + + '-pe "process.stdin.on(\'data\' , () => process.exit(1))"'; -var child = child_process.exec(cmd); -var output = ''; -var outputExpect = { 'code': 'EPIPE', - 'errno': 'EPIPE', - 'syscall': 'write' }; +const child = child_process.exec(cmd); +let output = ''; +const outputExpect = { + code: 'EPIPE', + errno: 'EPIPE', + syscall: 'write' +}; child.stderr.on('data', function(c) { output += c; }); -child.on('close', function(code) { + +child.on('close', common.mustCall(function(code) { try { output = JSON.parse(output); } catch (er) { @@ -31,4 +34,4 @@ child.on('close', function(code) { assert.deepEqual(output, outputExpect); console.log('ok'); -}); +}));