Browse Source

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

PR-URL: https://github.com/nodejs/node/pull/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>
v4.x
Travis Bretton 8 years ago
committed by Myles Borins
parent
commit
0f8a323546
No known key found for this signature in database GPG Key ID: 933B01F40B5CA946
  1. 29
      test/parallel/test-stdout-close-catch.js

29
test/parallel/test-stdout-close-catch.js

@ -1,27 +1,30 @@
'use strict'; 'use strict';
var common = require('../common'); const common = require('../common');
var assert = require('assert'); const assert = require('assert');
var path = require('path'); const path = require('path');
var child_process = require('child_process'); 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) + ' ' + const cmd = JSON.stringify(process.execPath) + ' ' +
JSON.stringify(testScript) + ' | ' + JSON.stringify(testScript) + ' | ' +
JSON.stringify(process.execPath) + ' ' + JSON.stringify(process.execPath) + ' ' +
'-pe "process.stdin.on(\'data\' , () => process.exit(1))"'; '-pe "process.stdin.on(\'data\' , () => process.exit(1))"';
var child = child_process.exec(cmd); const child = child_process.exec(cmd);
var output = ''; let output = '';
var outputExpect = { 'code': 'EPIPE', const outputExpect = {
'errno': 'EPIPE', code: 'EPIPE',
'syscall': 'write' }; errno: 'EPIPE',
syscall: 'write'
};
child.stderr.on('data', function(c) { child.stderr.on('data', function(c) {
output += c; output += c;
}); });
child.on('close', function(code) {
child.on('close', common.mustCall(function(code) {
try { try {
output = JSON.parse(output); output = JSON.parse(output);
} catch (er) { } catch (er) {
@ -31,4 +34,4 @@ child.on('close', function(code) {
assert.deepEqual(output, outputExpect); assert.deepEqual(output, outputExpect);
console.log('ok'); console.log('ok');
}); }));

Loading…
Cancel
Save