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

doc: add guidance on testing new errors #14207

Closed
wants to merge 3 commits into from

Conversation

mhdawson
Copy link
Member

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

doc, errors

@nodejs-github-bot nodejs-github-bot added the doc Issues and PRs related to the documentations. label Jul 12, 2017
@mhdawson mhdawson requested a review from jasnell July 12, 2017 21:48
as we can trust the error helper implementation. An example of this kind of
error would be:

```
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: language labels (js) after code backticks.

Copy link
Contributor

@vsemozhetbyt vsemozhetbyt Jul 12, 2017

Choose a reason for hiding this comment

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

Linter errors when the language added:

   94:1  error  Expected indentation of 2 spaces but found 4  indent
   95:1  error  Expected indentation of 2 spaces but found 4  indent
  107:1  error  Expected indentation of 0 spaces but found 1  indent
  108:1  error  Expected indentation of 2 spaces but found 4  indent
  109:1  error  Expected indentation of 0 spaces but found 2  indent
  110:1  error  Expected indentation of 2 spaces but found 4  indent
  111:1  error  Expected indentation of 2 spaces but found 4  indent
  112:1  error  Expected indentation of 0 spaces but found 2  indent

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for catching that.

@vsemozhetbyt vsemozhetbyt added errors Issues and PRs related to JavaScript errors originated in Node.js core. test Issues and PRs related to the tests. labels Jul 12, 2017
Copy link
Contributor

@refack refack left a comment

Choose a reason for hiding this comment

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

% lint

```

One final note is that it is bad practice to change the format of the message
after the error has been created and should avoided. If it does make sense
Copy link
Member

Choose a reason for hiding this comment

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

should avoided -> should be avoided

Although I'd rewrite this entire sentence as:

Avoid changing the format of the message after the error has been created.

Copy link
Member

Choose a reason for hiding this comment

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

Or even (if this is what is meant):

Avoid changing existing messages.

Copy link
Member Author

Choose a reason for hiding this comment

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

Took first suggested alternative sentence.

E('ERR_SOCKET_ALREADY_BOUND', 'Socket is already bound');
```

If the error message is not a constant string then test(s) to validate
Copy link
Contributor

Choose a reason for hiding this comment

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

Drop the parens in (s).

Copy link
Member Author

Choose a reason for hiding this comment

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

done

If the error message is not a constant string then test(s) to validate
the formatting of the message based on the parameters used when
creating the error should be added to
`.../test/parallel/test-internal-errors.js`. These tests should validate
Copy link
Contributor

Choose a reason for hiding this comment

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

Drop the .../

Copy link
Member Author

Choose a reason for hiding this comment

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

done

creating the error should be added to
`.../test/parallel/test-internal-errors.js`. These tests should validate
all of the different ways parameters can be used to generate the final
message string. As simple example would be:
Copy link
Contributor

Choose a reason for hiding this comment

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

As -> A
would be -> is

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@mhdawson
Copy link
Member Author

@vsemozhetbyt @Trott @cjihrig pushed change to address comments.

@mhdawson mhdawson self-assigned this Jul 13, 2017
In addition, there should also be tests which validate the use of the
error based on where it is used in the codebase. For these tests, except in
special cases, they should only validate that the expected code is received
and NOT validate the massage. This will reduce the amount of test change
Copy link
Member

Choose a reason for hiding this comment

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

s/massage/message/

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@mhdawson
Copy link
Member Author

@vsemozhetbyt
Copy link
Contributor

Linter CI is green.

@refack
Copy link
Contributor

refack commented Jul 14, 2017

mdlint is clean also:

D:\code\node-github-desktop\doc\guides$ node "D:\code\4node\mdlint\node_modules\remark-cli\cli.js" --rc-path "D:\code\4node\mdlint\remarkrc.txt" -f ./*.md
./backporting-to-release-lines.md: no issues found
./building-node-with-ninja.md: no issues found
./maintaining-V8.md: no issues found
./using-internal-errors.md: no issues found
./writing-and-running-benchmarks.md: no issues found
./writing-tests.md: no issues found

@mhdawson
Copy link
Member Author

CI was green, will land

@mhdawson
Copy link
Member Author

Landed as 9ab63d6

@mhdawson mhdawson closed this Jul 18, 2017
mhdawson added a commit that referenced this pull request Jul 18, 2017
PR-URL: #14207
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Vse Mozhet Byt <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@addaleax addaleax mentioned this pull request Jul 18, 2017
addaleax pushed a commit that referenced this pull request Jul 18, 2017
PR-URL: #14207
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Vse Mozhet Byt <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Fishrock123 pushed a commit that referenced this pull request Jul 19, 2017
PR-URL: #14207
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Vse Mozhet Byt <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@mhdawson mhdawson deleted the errors-doc branch September 30, 2019 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations. errors Issues and PRs related to JavaScript errors originated in Node.js core. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants