-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
test: improve logged errors #31425
Conversation
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/testing @nodejs/util PTAL. This improves the terminal output for multiple error cases in our tests. |
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. |
@@ -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()); |
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.
What's an example of a situation where this will result in a better stack?
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.
Node.js core frames are visualized in grey. It makes it easier to distinguish the test code from core code.
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.
LGTM
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]>
Landed in 1450ea7 🎉 |
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 if this is something that should be in |
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]>
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]>
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), orvcbuild test
(Windows) passes