Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: assert unused vars in test-cli-eval.js #10759

Closed
wants to merge 3 commits into from
Closed

test: assert unused vars in test-cli-eval.js #10759

wants to merge 3 commits into from

Conversation

StarryShark
Copy link
Contributor

Assert unused variables in test-cli-eval.js

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

test

@nodejs-github-bot nodejs-github-bot added test Issues and PRs related to the tests. dont-land-on-v7.x labels Jan 12, 2017
@@ -19,13 +19,15 @@ const filename = __filename.replace(/\\/g, '/');
// assert that nothing is written to stdout
child.exec(nodejs + ' --eval 42',
function(err, stdout, stderr) {
assert.strictEqual(err, null);
Copy link
Member

Choose a reason for hiding this comment

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

These will work and are totally fine, but it's probably more idiomatic to do this:

assert.ifError(err);

@@ -36,12 +38,14 @@ child.exec(nodejs + ' --eval "console.error(42)"',

child.exec(cmd + '42',
function(err, stdout, stderr) {
assert.strictEqual(typeof err, 'object');
Copy link
Member

Choose a reason for hiding this comment

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

This is OK, but is probably better like this:

assert(err instanceof Error);

Even better if the type of error is known. For example, if it's expected to be a RangeError, then assert.(err instanceof RangeError) etc.

@mscdex mscdex added process Issues and PRs related to the process subsystem. and removed dont-land-on-v7.x labels Jan 12, 2017
Copy link
Member

@Trott Trott left a comment

Choose a reason for hiding this comment

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

LGTM if CI is green, although if you want to make the changes in the nits I left, even better.

@Trott
Copy link
Member

Trott commented Jan 12, 2017

@Trott
Copy link
Member

Trott commented Jan 12, 2017

I suspect that ideally status should be renamed err and treated like the err object (using assert.ifError() rather than checking for equality to null). I wouldn't hold this up over that. Might make a good next contribution, though. (If you do want to change it in this PR, though, go for it!)

@StarryShark
Copy link
Contributor Author

@Trott made a commit to rename status to err. please review.

@Trott
Copy link
Member

Trott commented Jan 12, 2017

LGTM. Let's run CI again...

CI: https://ci.nodejs.org/job/node-test-pull-request/5838/

jasnell pushed a commit that referenced this pull request Jan 16, 2017
* assert unused vars in test-cli-eval.js
* assert in more idiomatic way test-cli-eval
* rename status to err in test-cli-eval.js

PR-URL: #10759
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@jasnell
Copy link
Member

jasnell commented Jan 16, 2017

Landed in b9adbf2

@jasnell jasnell closed this Jan 16, 2017
@cjihrig
Copy link
Contributor

cjihrig commented Jan 16, 2017

Looks like this broke the CI on Windows. Fix in #10840.

italoacasas pushed a commit to italoacasas/node that referenced this pull request Jan 18, 2017
* assert unused vars in test-cli-eval.js
* assert in more idiomatic way test-cli-eval
* rename status to err in test-cli-eval.js

PR-URL: nodejs#10759
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
italoacasas pushed a commit to italoacasas/node that referenced this pull request Jan 23, 2017
* assert unused vars in test-cli-eval.js
* assert in more idiomatic way test-cli-eval
* rename status to err in test-cli-eval.js

PR-URL: nodejs#10759
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
targos pushed a commit that referenced this pull request Jan 28, 2017
* assert unused vars in test-cli-eval.js
* assert in more idiomatic way test-cli-eval
* rename status to err in test-cli-eval.js

PR-URL: #10759
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@italoacasas italoacasas mentioned this pull request Jan 29, 2017
italoacasas pushed a commit to italoacasas/node that referenced this pull request Jan 30, 2017
* assert unused vars in test-cli-eval.js
* assert in more idiomatic way test-cli-eval
* rename status to err in test-cli-eval.js

PR-URL: nodejs#10759
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
italoacasas pushed a commit to italoacasas/node that referenced this pull request Jan 30, 2017
* assert unused vars in test-cli-eval.js
* assert in more idiomatic way test-cli-eval
* rename status to err in test-cli-eval.js

PR-URL: nodejs#10759
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@MylesBorins
Copy link
Contributor

This does not land cleanly in LTS. Added dont-land label. Please feel free to manually backport

If it is backported please include #10840

MylesBorins pushed a commit that referenced this pull request Apr 18, 2017
* assert unused vars in test-cli-eval.js
* assert in more idiomatic way test-cli-eval
* rename status to err in test-cli-eval.js

PR-URL: #10759
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit that referenced this pull request Apr 19, 2017
* assert unused vars in test-cli-eval.js
* assert in more idiomatic way test-cli-eval
* rename status to err in test-cli-eval.js

PR-URL: #10759
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@MylesBorins MylesBorins mentioned this pull request Apr 19, 2017
andrew749 pushed a commit to michielbaird/node that referenced this pull request Jul 19, 2017
* assert unused vars in test-cli-eval.js
* assert in more idiomatic way test-cli-eval
* rename status to err in test-cli-eval.js

PR-URL: nodejs/node#10759
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
process Issues and PRs related to the process subsystem. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants