Skip to content

Commit

Permalink
test: favor strict equality in test-exec
Browse files Browse the repository at this point in the history
PR-URL: #8173
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
  • Loading branch information
Trott authored and MylesBorins committed Oct 26, 2016
1 parent 558f7d9 commit 2997b79
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions test/pummel/test-exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ exec(
console.log('error!: ' + err.code);
console.log('stdout: ' + JSON.stringify(stdout));
console.log('stderr: ' + JSON.stringify(stderr));
assert.equal(false, err.killed);
assert.strictEqual(false, err.killed);
} else {
success_count++;
console.dir(stdout);
Expand All @@ -38,17 +38,19 @@ exec(
exec('thisisnotavalidcommand', function(err, stdout, stderr) {
if (err) {
error_count++;
assert.equal('', stdout);
assert.equal(true, err.code != 0);
assert.equal(false, err.killed);
assert.strictEqual('', stdout);
assert.strictEqual(typeof err.code, 'number');
assert.notStrictEqual(err.code, 0);
assert.strictEqual(false, err.killed);
assert.strictEqual(null, err.signal);
console.log('error code: ' + err.code);
console.log('stdout: ' + JSON.stringify(stdout));
console.log('stderr: ' + JSON.stringify(stderr));
} else {
success_count++;
console.dir(stdout);
assert.equal(true, stdout != '');
assert.strictEqual(typeof stdout, 'string');
assert.notStrictEqual(stdout, '');
}
});

Expand All @@ -60,7 +62,7 @@ exec(SLEEP3_COMMAND, { timeout: 50 }, function(err, stdout, stderr) {
assert.ok(diff < 500);
assert.ok(err);
assert.ok(err.killed);
assert.equal(err.signal, 'SIGTERM');
assert.strictEqual(err.signal, 'SIGTERM');
});


Expand All @@ -71,7 +73,7 @@ process.nextTick(function() {
console.log('kill pid %d', killMeTwice.pid);
// make sure there is no race condition in starting the process
// the PID SHOULD exist directly following the exec() call.
assert.equal('number', typeof killMeTwice._handle.pid);
assert.strictEqual('number', typeof killMeTwice._handle.pid);
// Kill the process
killMeTwice.kill();
});
Expand All @@ -82,7 +84,7 @@ function killMeTwiceCallback(err, stdout, stderr) {
// works and that we are getting the proper callback parameters.
assert.ok(err);
assert.ok(err.killed);
assert.equal(err.signal, 'SIGTERM');
assert.strictEqual(err.signal, 'SIGTERM');

// the timeout should still be in effect
console.log('\'sleep 3\' was already killed. Took %d ms', diff);
Expand All @@ -98,6 +100,6 @@ exec('python -c "print 200000*\'C\'"', {maxBuffer: 1000},


process.on('exit', function() {
assert.equal(1, success_count);
assert.equal(1, error_count);
assert.strictEqual(1, success_count);
assert.strictEqual(1, error_count);
});

0 comments on commit 2997b79

Please sign in to comment.