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: improve logged errors #31425

Closed

Conversation

BridgeAR
Copy link
Member

@BridgeAR BridgeAR commented Jan 20, 2020

To indicate which lines are test lines and which are from Node.js core,
it's good to rely upon util.inspect() while inspecting errors. Using it also logs error properties and provides more informations about the error.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

To indicate which lines are test lines and which from Node.js core,
it's good to rely on `util.inspect()` while inspecting errors.

The stack was accessed directly instead in multiple cases and logging
that does not provide as much information as using `util.inspect()`.
@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label Jan 20, 2020
@nodejs-github-bot
Copy link
Collaborator

@BridgeAR
Copy link
Member Author

@nodejs/testing @nodejs/util PTAL. This improves the terminal output for multiple error cases in our tests.

@Trott
Copy link
Member

Trott commented Jan 23, 2020

LGTM. Might be a good idea to post something in a comment here showing the before/after difference. Might be useful for both current reviewers and people doing git-archaeology at a later date.

test/common/index.js Outdated Show resolved Hide resolved
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@@ -139,19 +139,22 @@ if (process.env.NODE_TEST_WITH_ASYNC_HOOKS) {
process._rawDebug();
throw new Error(`same id added to destroy list twice (${id})`);
}
destroyListList[id] = new Error().stack;
destroyListList[id] = util.inspect(new Error());
Copy link
Member

Choose a reason for hiding this comment

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

What's an example of a situation where this will result in a better stack?

Copy link
Member Author

Choose a reason for hiding this comment

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

Node.js core frames are visualized in grey. It makes it easier to distinguish the test code from core code.

Copy link
Contributor

@antsmartian antsmartian left a comment

Choose a reason for hiding this comment

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

LGTM

BridgeAR added a commit that referenced this pull request Feb 9, 2020
To indicate which lines are test lines and which from Node.js core,
it's good to rely on `util.inspect()` while inspecting errors.

The stack was accessed directly instead in multiple cases and logging
that does not provide as much information as using `util.inspect()`.

PR-URL: #31425
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Anto Aravinth <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Yihong Wang <[email protected]>
@BridgeAR
Copy link
Member Author

BridgeAR commented Feb 9, 2020

Landed in 1450ea7 🎉

@BridgeAR BridgeAR closed this Feb 9, 2020
codebytere pushed a commit that referenced this pull request Feb 17, 2020
To indicate which lines are test lines and which from Node.js core,
it's good to rely on `util.inspect()` while inspecting errors.

The stack was accessed directly instead in multiple cases and logging
that does not provide as much information as using `util.inspect()`.

PR-URL: #31425
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Anto Aravinth <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Yihong Wang <[email protected]>
@codebytere codebytere mentioned this pull request Feb 17, 2020
@codebytere
Copy link
Member

codebytere commented Mar 15, 2020

@BridgeAR if this is something that should be in v12.x, could you please manually backport it there?

targos pushed a commit to targos/node that referenced this pull request Apr 25, 2020
To indicate which lines are test lines and which from Node.js core,
it's good to rely on `util.inspect()` while inspecting errors.

The stack was accessed directly instead in multiple cases and logging
that does not provide as much information as using `util.inspect()`.

PR-URL: nodejs#31425
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Anto Aravinth <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Yihong Wang <[email protected]>
targos pushed a commit that referenced this pull request Apr 28, 2020
To indicate which lines are test lines and which from Node.js core,
it's good to rely on `util.inspect()` while inspecting errors.

The stack was accessed directly instead in multiple cases and logging
that does not provide as much information as using `util.inspect()`.

PR-URL: #31425
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Anto Aravinth <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Yihong Wang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants