-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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: migrate message util tests from Python to JS #49721 #50333
base: main
Are you sure you want to change the base?
Changes from 3 commits
d542f8e
068e098
985dfc5
f5489c1
eae8b32
bdb6a39
e399adb
93e0aca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
'use strict'; | ||
|
||
require('../common'); | ||
require('../../common'); | ||
|
||
const { inspect } = require('util'); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
Error: Number error cause | ||
at * | ||
at * | ||
at * | ||
at * | ||
at * | ||
at * | ||
at * { | ||
[cause]: 42 | ||
} | ||
Error: Object cause | ||
at * | ||
at * | ||
at * | ||
at * | ||
at * | ||
at * | ||
at * { | ||
[cause]: { | ||
message: 'Unique', | ||
name: 'Error', | ||
stack: 'Error: Unique\n' + | ||
' at Module._compile (node:internal*modules*cjs*loader**)' | ||
} | ||
} | ||
Error: undefined cause | ||
at * | ||
at * | ||
at * | ||
at * | ||
at * | ||
at * | ||
at * { | ||
[cause]: undefined | ||
} | ||
Error: cause that throws | ||
at * | ||
at * | ||
at * | ||
at * | ||
at * | ||
at * | ||
at * { | ||
[cause]: [Getter] | ||
} | ||
RangeError: New Stack Frames | ||
at * | ||
[90m at process.processTicksAndRejections (node:internal*process*task_queues**)[39m { | ||
[cause]: FoobarError: Individual message | ||
at Object.<anonymous> [90m(*[39mtest*fixtures*util*util-inspect-error-cause.js**[90m)[39m | ||
[90m at Module._compile (node:internal*modules*cjs*loader**)[39m | ||
[90m ... 4 lines matching cause stack trace ...[39m | ||
[90m at node:internal*main*run_main_module**[39m { | ||
status: [32m'Feeling good'[39m, | ||
extraProperties: [32m'Yes!'[39m, | ||
[cause]: TypeError: Inner error | ||
at Object.<anonymous> [90m(*[39mtest*fixtures*util*util-inspect-error-cause.js**[90m)[39m | ||
[90m at Module._compile (node:internal*modules*cjs*loader**)[39m | ||
[90m at Module._extensions..js (node:internal*modules*cjs*loader**)[39m | ||
[90m at Module.load (node:internal*modules*cjs*loader**)[39m | ||
[90m at Module._load (node:internal*modules*cjs*loader**)[39m | ||
[90m at Function.executeUserEntryPoint [as runMain] (node:internal*modules*run_main**)[39m | ||
[90m at node:internal*main*run_main_module**[39m | ||
} | ||
} | ||
Error: Stack causes | ||
at Object.<anonymous> [90m(*[39mtest*fixtures*util*util-inspect-error-cause.js**[90m)[39m | ||
[90m at Module._compile (node:internal*modules*cjs*loader**)[39m | ||
[90m ... 4 lines matching cause stack trace ...[39m | ||
[90m at node:internal*main*run_main_module**[39m { | ||
[cause]: FoobarError: Individual message | ||
at Object.<anonymous> [90m(*[39mtest*fixtures*util*util-inspect-error-cause.js**[90m)[39m | ||
[90m at Module._compile (node:internal*modules*cjs*loader**)[39m | ||
[90m ... 4 lines matching cause stack trace ...[39m | ||
[90m at node:internal*main*run_main_module**[39m { | ||
status: [32m'Feeling good'[39m, | ||
extraProperties: [32m'Yes!'[39m, | ||
[cause]: TypeError: Inner error | ||
at Object.<anonymous> [90m(*[39mtest*fixtures*util*util-inspect-error-cause.js**[90m)[39m | ||
[90m at Module._compile (node:internal*modules*cjs*loader**)[39m | ||
[90m at Module._extensions..js (node:internal*modules*cjs*loader**)[39m | ||
[90m at Module.load (node:internal*modules*cjs*loader**)[39m | ||
[90m at Module._load (node:internal*modules*cjs*loader**)[39m | ||
[90m at Function.executeUserEntryPoint [as runMain] (node:internal*modules*run_main**)[39m | ||
[90m at node:internal*main*run_main_module**[39m | ||
} | ||
} | ||
RangeError: New Stack Frames | ||
at * | ||
[90m at process.processTicksAndRejections (node:internal*process*task_queues**)[39m { | ||
[cause]: Error: Stack causes | ||
at Object.<anonymous> [90m(*[39mtest*fixtures*util*util-inspect-error-cause.js**[90m)[39m | ||
[90m at Module._compile (node:internal*modules*cjs*loader**)[39m | ||
[90m ... 4 lines matching cause stack trace ...[39m | ||
[90m at node:internal*main*run_main_module**[39m { | ||
[cause]: FoobarError: Individual message | ||
at Object.<anonymous> [90m(*[39mtest*fixtures*util*util-inspect-error-cause.js**[90m)[39m | ||
[90m at Module._compile (node:internal*modules*cjs*loader**)[39m | ||
[90m ... 4 lines matching cause stack trace ...[39m | ||
[90m at node:internal*main*run_main_module**[39m { | ||
status: [32m'Feeling good'[39m, | ||
extraProperties: [32m'Yes!'[39m, | ||
[cause]: TypeError: Inner error | ||
at Object.<anonymous> [90m(*[39mtest*fixtures*util*util-inspect-error-cause.js**[90m)[39m | ||
[90m at Module._compile (node:internal*modules*cjs*loader**)[39m | ||
[90m at Module._extensions..js (node:internal*modules*cjs*loader**)[39m | ||
[90m at Module.load (node:internal*modules*cjs*loader**)[39m | ||
[90m at Module._load (node:internal*modules*cjs*loader**)[39m | ||
[90m at Function.executeUserEntryPoint [as runMain] (node:internal*modules*run_main**)[39m | ||
[90m at node:internal*main*run_main_module**[39m | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don’t want these internals in the snapshots. Renaming a method within the module loader shouldn’t break this unrelated test. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey @GeoffreyBooth or @MoLow , I have a question. I'm making my edits in this PR after realizing I was going about it the wrong way. I'm having a hard time knowing when it's okay to edit the snapshot in order to get the tests to pass. I'm using past commits as a reference. But my question is, for the following, can I edit the snapshot to take " * " or should I edit my JS file to replace " * " with "90m" and "39m"?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should not edit the snapshots manually, use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @MoLow The linter don't like the control characters.
|
||
} | ||
} | ||
} | ||
RangeError: New Stack Frames | ||
at * | ||
at * { | ||
[cause]: FoobarError: Individual message | ||
at * | ||
at * | ||
... 4 lines matching cause stack trace ... | ||
at * { | ||
status: 'Feeling good', | ||
extraProperties: 'Yes!', | ||
[cause]: TypeError: Inner error | ||
at * | ||
at * | ||
at * | ||
at * | ||
at * | ||
at * | ||
at * | ||
} | ||
} | ||
Error: Stack causes | ||
at * | ||
at * | ||
... 4 lines matching cause stack trace ... | ||
at * { | ||
[cause]: FoobarError: Individual message | ||
at * | ||
at * | ||
... 4 lines matching cause stack trace ... | ||
at * { | ||
status: 'Feeling good', | ||
extraProperties: 'Yes!', | ||
[cause]: TypeError: Inner error | ||
at * | ||
at * | ||
at * | ||
at * | ||
at * | ||
at * | ||
at * | ||
} | ||
} | ||
RangeError: New Stack Frames | ||
at * | ||
at * { | ||
[cause]: Error: Stack causes | ||
at * | ||
at * | ||
... 4 lines matching cause stack trace ... | ||
at * { | ||
[cause]: FoobarError: Individual message | ||
at * | ||
at * | ||
... 4 lines matching cause stack trace ... | ||
at * { | ||
status: 'Feeling good', | ||
extraProperties: 'Yes!', | ||
[cause]: TypeError: Inner error | ||
at * | ||
at * | ||
at * | ||
at * | ||
at * | ||
at * | ||
at * | ||
} | ||
} | ||
} |
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.
Add
Error.stackTraceLimit = 0
(or1
) before the test is run to remove these call stack lines that we don’t care about. Search forError.stackTraceLimit
in other tests to see examples.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.
@GeoffreyBooth
Added the following in the .js file locally
Error.stackTraceLimit = 7;
and it worked for me
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.
Using 0 instead of 7 should help suppress the stack trace lines that show the module internals (my other note).
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.
@GeoffreyBooth I'm assuming I should be adding the line in my
test-node-output-util.js
file and not the files under fixtures/util? I ran into issues doing that, but not when adding the line to my file under parallel.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 don’t remember. If you search for
Error.stackTraceLimit = 0
in the other test files you can copy the pattern they use.