Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Adding unit test for crash on missing arguments.
  • Loading branch information
Bryce Simonds committed May 24, 2016
commit 1eaeb81818dd2d093408a70e384bc5a24ca6e381
9 changes: 7 additions & 2 deletions test/parallel/test-cli-eval.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const child = require('child_process');
const path = require('path');
const nodejs = '"' + process.execPath + '"';


// replace \ by / because windows uses backslashes in paths, but they're still
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you undo the whitespace changes in the lines your changes don’t touch? That helps when running e.g. git blame on a file

// interpreted as the escape character when put between quotes.
var filename = __filename.replace(/\\/g, '/');
Expand Down Expand Up @@ -66,8 +65,14 @@ child.exec(nodejs + ' --eval "require(\'./test/parallel/test-cli-eval.js\')"',
assert.equal(status.code, 42);
});

// Missing argument should not crash
child.exec(nodejs + ' -e', function (status, stdout, stderr) {
assert.notStrictEqual(status, null);
assert.equal(status.code, 9);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: It’s generally preferred to use assert.strictEqual over assert.equal

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use strictEqual

});

// empty program should do nothing
child.exec(nodejs + ' -e ""', function(status, stdout, stderr) {
child.exec(nodejs + ' -e ""', function (status, stdout, stderr) {
assert.equal(stdout, '');
assert.equal(stderr, '');
});
Expand Down