Browse Source

test: refactor test-stdin-script-child

- var -> const where possible
- assert.equal -> assert.strictEqual
- passed the setTimeout function a second parameter for readability
- used assert.strictEqual for assert(!c) as it is expected to be 0 and
  not some other value

PR-URL: https://github.com/nodejs/node/pull/10321
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Italo A. Casas <me@italoacasas.com>
v6
Emanuel Buholzer 8 years ago
committed by Italo A. Casas
parent
commit
bc57f241fa
  1. 20
      test/parallel/test-stdin-script-child.js

20
test/parallel/test-stdin-script-child.js

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

Loading…
Cancel
Save