Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cfbafd7

Browse filesBrowse files
Trottevanlucas
authored andcommitted
test: favor strict equality in test-exec
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>
1 parent 0c9960b commit cfbafd7
Copy full SHA for cfbafd7

File tree

Expand file treeCollapse file tree

1 file changed

+12
-10
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+12
-10
lines changed
Open diff view settings
Collapse file

‎test/pummel/test-exec.js‎

Copy file name to clipboardExpand all lines: test/pummel/test-exec.js
+12-10Lines changed: 12 additions & 10 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.