Skip to content

Commit

Permalink
test: cleanup test-stdout-close-catch.js
Browse files Browse the repository at this point in the history
Added common.mustCall in child process on 'close' callback
Changed several 'var' statements to 'const' or 'let' where appropriate
Also linting

PR-URL: #10006
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
  • Loading branch information
furnox authored and targos committed Dec 26, 2016
1 parent 49e7029 commit ff3a1e6
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions test/parallel/test-stdout-close-catch.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -31,4 +34,4 @@ child.on('close', function(code) {

assert.deepStrictEqual(output, outputExpect);
console.log('ok');
});
}));

0 comments on commit ff3a1e6

Please sign in to comment.