Skip to content

Commit 2997b79

Browse files
TrottMylesBorins
authored andcommitted
test: favor strict equality in test-exec
PR-URL: #8173 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent 558f7d9 commit 2997b79

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

test/pummel/test-exec.js

+12-10
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ exec(
2626
console.log('error!: ' + err.code);
2727
console.log('stdout: ' + JSON.stringify(stdout));
2828
console.log('stderr: ' + JSON.stringify(stderr));
29-
assert.equal(false, err.killed);
29+
assert.strictEqual(false, err.killed);
3030
} else {
3131
success_count++;
3232
console.dir(stdout);
@@ -38,17 +38,19 @@ exec(
3838
exec('thisisnotavalidcommand', function(err, stdout, stderr) {
3939
if (err) {
4040
error_count++;
41-
assert.equal('', stdout);
42-
assert.equal(true, err.code != 0);
43-
assert.equal(false, err.killed);
41+
assert.strictEqual('', stdout);
42+
assert.strictEqual(typeof err.code, 'number');
43+
assert.notStrictEqual(err.code, 0);
44+
assert.strictEqual(false, err.killed);
4445
assert.strictEqual(null, err.signal);
4546
console.log('error code: ' + err.code);
4647
console.log('stdout: ' + JSON.stringify(stdout));
4748
console.log('stderr: ' + JSON.stringify(stderr));
4849
} else {
4950
success_count++;
5051
console.dir(stdout);
51-
assert.equal(true, stdout != '');
52+
assert.strictEqual(typeof stdout, 'string');
53+
assert.notStrictEqual(stdout, '');
5254
}
5355
});
5456

@@ -60,7 +62,7 @@ exec(SLEEP3_COMMAND, { timeout: 50 }, function(err, stdout, stderr) {
6062
assert.ok(diff < 500);
6163
assert.ok(err);
6264
assert.ok(err.killed);
63-
assert.equal(err.signal, 'SIGTERM');
65+
assert.strictEqual(err.signal, 'SIGTERM');
6466
});
6567

6668

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

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

99101

100102
process.on('exit', function() {
101-
assert.equal(1, success_count);
102-
assert.equal(1, error_count);
103+
assert.strictEqual(1, success_count);
104+
assert.strictEqual(1, error_count);
103105
});

0 commit comments

Comments
 (0)