From c755afa8a6325b6fa07165ffd6e3ece76ef54adc Mon Sep 17 00:00:00 2001 From: Travis Bretton Date: Thu, 1 Dec 2016 09:53:01 -0700 Subject: [PATCH 1/2] test: cleanup test-stdout-close-catch.js Added common.mustCall in child process on 'close' callback Changed several 'var' statements to 'const' or 'let' where appropriate Also linting --- test/parallel/test-stdout-close-catch.js | 29 ++++++++++++------------ 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/test/parallel/test-stdout-close-catch.js b/test/parallel/test-stdout-close-catch.js index d84d8e93b0c0b0..da99c3242559b3 100644 --- a/test/parallel/test-stdout-close-catch.js +++ b/test/parallel/test-stdout-close-catch.js @@ -1,19 +1,19 @@ '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', +const child = child_process.exec(cmd); +let output = ''; +const outputExpect = { 'code': 'EPIPE', 'errno': 'EPIPE', 'syscall': 'write' }; @@ -21,7 +21,8 @@ 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 +32,4 @@ child.on('close', function(code) { assert.deepStrictEqual(output, outputExpect); console.log('ok'); -}); +}), 1); From ab0a3b2050e726731e4bd3be0dcc3c6075a8985b Mon Sep 17 00:00:00 2001 From: tlb Date: Tue, 13 Dec 2016 23:35:30 -0700 Subject: [PATCH 2/2] test: fixed mustCall default, coding style fixes Defaulting to mustCall number of 1. Indenting obj properties --- test/parallel/test-stdout-close-catch.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-stdout-close-catch.js b/test/parallel/test-stdout-close-catch.js index da99c3242559b3..322ed76aee8fc0 100644 --- a/test/parallel/test-stdout-close-catch.js +++ b/test/parallel/test-stdout-close-catch.js @@ -13,9 +13,11 @@ const cmd = JSON.stringify(process.execPath) + ' ' + const child = child_process.exec(cmd); let output = ''; -const outputExpect = { 'code': 'EPIPE', - 'errno': 'EPIPE', - 'syscall': 'write' }; +const outputExpect = { + code: 'EPIPE', + errno: 'EPIPE', + syscall: 'write' +}; child.stderr.on('data', function(c) { output += c; @@ -32,4 +34,4 @@ child.on('close', common.mustCall(function(code) { assert.deepStrictEqual(output, outputExpect); console.log('ok'); -}), 1); +}));