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: migrate message util tests from Python to JS #49721 #50333

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

require('../common');
require('../../common');

const { inspect } = require('util');

Expand Down
181 changes: 181 additions & 0 deletions test/fixtures/util/util-inspect-error-cause.snapshot
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]: *
}
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 *
*[*m at *[*m {
[cause]: FoobarError: Individual message
at Object.<anonymous> *[*m(**[*mtest*fixtures*util*util-inspect-error-cause.js:*:**[*m)*[*m
*[*m at Module._compile (node:internal*modules*cjs*loader:*:*)*[*m
*[*m ... * lines matching cause stack trace ...*[*m
*[*m at *[*m {
status: *[*m'Feeling good'*[*m,
extraProperties: *[*m'Yes!'*[*m,
[cause]: TypeError: Inner error
at Object.<anonymous> *[*m(**[*mtest*fixtures*util*util-inspect-error-cause.js:*:**[*m)*[*m
*[*m at Module._compile (node:internal*modules*cjs*loader:*:*)*[*m
*[*m at Module._extensions..js (node:internal*modules*cjs*loader:*:*)*[*m
*[*m at Module.load (node:internal*modules*cjs*loader:*:*)*[*m
*[*m at Module._load (node:internal*modules*cjs*loader:*:*)*[*m
*[*m at Function.executeUserEntryPoint [as runMain] (node:internal*modules*run_main:*:*)*[*m
*[*m at *[*m
Comment on lines +57 to +63
Copy link
Member

Choose a reason for hiding this comment

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

None of these functions should be in the stack trace. I should be able to refactor the internals of the CommonJS loader without breaking unrelated tests.

}
}
Error: Stack causes
at Object.<anonymous> *[*m(**[*mtest*fixtures*util*util-inspect-error-cause.js:*:**[*m)*[*m
*[*m at Module._compile (node:internal*modules*cjs*loader:*:*)*[*m
*[*m ... * lines matching cause stack trace ...*[*m
*[*m at *[*m {
[cause]: FoobarError: Individual message
at Object.<anonymous> *[*m(**[*mtest*fixtures*util*util-inspect-error-cause.js:*:**[*m)*[*m
*[*m at Module._compile (node:internal*modules*cjs*loader:*:*)*[*m
*[*m ... * lines matching cause stack trace ...*[*m
*[*m at *[*m {
status: *[*m'Feeling good'*[*m,
extraProperties: *[*m'Yes!'*[*m,
[cause]: TypeError: Inner error
at Object.<anonymous> *[*m(**[*mtest*fixtures*util*util-inspect-error-cause.js:*:**[*m)*[*m
*[*m at Module._compile (node:internal*modules*cjs*loader:*:*)*[*m
*[*m at Module._extensions..js (node:internal*modules*cjs*loader:*:*)*[*m
*[*m at Module.load (node:internal*modules*cjs*loader:*:*)*[*m
*[*m at Module._load (node:internal*modules*cjs*loader:*:*)*[*m
*[*m at Function.executeUserEntryPoint [as runMain] (node:internal*modules*run_main:*:*)*[*m
*[*m at *[*m
}
}
RangeError: New Stack Frames
at *
*[*m at *[*m {
[cause]: Error: Stack causes
at Object.<anonymous> *[*m(**[*mtest*fixtures*util*util-inspect-error-cause.js:*:**[*m)*[*m
*[*m at Module._compile (node:internal*modules*cjs*loader:*:*)*[*m
*[*m ... * lines matching cause stack trace ...*[*m
*[*m at *[*m {
[cause]: FoobarError: Individual message
at Object.<anonymous> *[*m(**[*mtest*fixtures*util*util-inspect-error-cause.js:*:**[*m)*[*m
*[*m at Module._compile (node:internal*modules*cjs*loader:*:*)*[*m
*[*m ... * lines matching cause stack trace ...*[*m
*[*m at *[*m {
status: *[*m'Feeling good'*[*m,
extraProperties: *[*m'Yes!'*[*m,
[cause]: TypeError: Inner error
at Object.<anonymous> *[*m(**[*mtest*fixtures*util*util-inspect-error-cause.js:*:**[*m)*[*m
*[*m at Module._compile (node:internal*modules*cjs*loader:*:*)*[*m
*[*m at Module._extensions..js (node:internal*modules*cjs*loader:*:*)*[*m
*[*m at Module.load (node:internal*modules*cjs*loader:*:*)*[*m
*[*m at Module._load (node:internal*modules*cjs*loader:*:*)*[*m
*[*m at Function.executeUserEntryPoint [as runMain] (node:internal*modules*run_main:*:*)*[*m
*[*m at *[*m
}
}
}
RangeError: New Stack Frames
at *
at * {
[cause]: FoobarError: Individual message
at *
at *
... * 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 *
... * lines matching cause stack trace ...
at * {
[cause]: FoobarError: Individual message
at *
at *
... * 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 *
... * lines matching cause stack trace ...
at * {
[cause]: FoobarError: Individual message
at *
at *
... * lines matching cause stack trace ...
at * {
status: 'Feeling good',
extraProperties: 'Yes!',
[cause]: TypeError: Inner error
at *
at *
at *
at *
at *
at *
at *
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

require('../common');
require('../../common');
const util = require('util');

const err = new Error('foo\nbar');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
{ err:
Error: foo
bar
at *util_inspect_error*
at *
at *
at *
at *
at *
at *
at ,
nested:
{ err:
Error: foo
bar
at *util_inspect_error*
at *
at *
at *
at *
at *
at *
at } }
{
err: Error: foo
bar
at *util_inspect_error*
at *
at *
at *
at *
at *
at *
at ,
nested: {
err: Error: foo
bar
at *util_inspect_error*
at *
at *
at *
at *
Expand All @@ -43,7 +43,7 @@
}
{ Error: foo
bar
at *util_inspect_error*
at *
at *
at *
at *
Expand Down
Loading