-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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: improve the code in test-process-cpuUsage #10714
Conversation
@@ -33,27 +33,57 @@ for (let i = 0; i < 10; i++) { | |||
assert(diffUsage.system >= 0); | |||
} | |||
|
|||
const invalidUserArgument = new RegExp('TypeError: value of user ' + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add ^
and $
to these regular expressions.
0102f0f
to
b659719
Compare
@cjihrig sorry, forgot that... just fixed it |
@@ -33,27 +33,57 @@ for (let i = 0; i < 10; i++) { | |||
assert(diffUsage.system >= 0); | |||
} | |||
|
|||
const invalidUserArgument = new RegExp('^TypeError: value of user ' + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason to not write these as:
const invalidUserArgument =
/^TypeError: value of user property of argument is invalid$/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cjihrig, honestIy would like to do it that way ... but can not find consensus about identation, got requests to change things when doing something like that in previous commits ... is there any document detailing the official code style? the linter seems to be fine with the previous commits but reviewers don't agree... so... would really love to understand when is fine to use an identation like the one you are suggesting and when I should keep it in line after the =
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the official style is what I suggested (although I can't remember if the indentation on the next line is supposed to be 2 or 4 spaces).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think 4 (i.e. an extra indent to separate it from any indented code on the next line)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be really nice to have a guide for this...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@edsadr it would be great to have it documented, I'm not sure where, maybe in the test-writing guide for now? I think the easiest way to get started would be to raise a PR with whatever you think it should be, @mention nodejs/collaborators, and see what the consensus is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gibfahn thanks, I think is worth it to have a basic one and will work in something like that for a PR
* validate the errors for assert.throws * use arrow functions
b659719
to
edbcd43
Compare
@cjihrig changed the RegExp now 🙂 |
Landed c963094 |
* validate the errors for assert.throws * use arrow functions PR-URL: #10714 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
* validate the errors for assert.throws * use arrow functions PR-URL: nodejs#10714 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
* validate the errors for assert.throws * use arrow functions PR-URL: nodejs#10714 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
* validate the errors for assert.throws * use arrow functions PR-URL: nodejs#10714 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
* validate the errors for assert.throws * use arrow functions PR-URL: nodejs#10714 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
* validate the errors for assert.throws * use arrow functions PR-URL: #10714 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
* validate the errors for assert.throws * use arrow functions PR-URL: #10714 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
* validate the errors for assert.throws * use arrow functions PR-URL: #10714 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
* validate the errors for assert.throws * use arrow functions PR-URL: #10714 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
test