diff --git a/test/parallel/test-stdin-script-child.js b/test/parallel/test-stdin-script-child.js index ad65734364..091c5cb29a 100644 --- a/test/parallel/test-stdin-script-child.js +++ b/test/parallel/test-stdin-script-child.js @@ -1,14 +1,14 @@ 'use strict'; -require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); -var spawn = require('child_process').spawn; -var child = spawn(process.execPath, [], { +const spawn = require('child_process').spawn; +const child = spawn(process.execPath, [], { env: Object.assign(process.env, { NODE_DEBUG: process.argv[2] }) }); -var wanted = child.pid + '\n'; +const wanted = child.pid + '\n'; var found = ''; child.stdout.setEncoding('utf8'); @@ -21,12 +21,12 @@ child.stderr.on('data', function(c) { console.error('> ' + c.trim().split(/\n/).join('\n> ')); }); -child.on('close', function(c) { - assert(!c); - assert.equal(found, wanted); +child.on('close', common.mustCall(function(c) { + assert.strictEqual(c, 0); + assert.strictEqual(found, wanted); console.log('ok'); -}); +})); setTimeout(function() { child.stdin.end('console.log(process.pid)'); -}); +}, 1);