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: migrated test/message to JS fixture tests #47868

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
8 changes: 4 additions & 4 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,10 @@ tools/test.py child-process
```

You can also execute the tests in a test suite directory
(such as `test/message`):
(such as `test/report`):

```bash
tools/test.py test/message
```text
$ tools/test.py test/report
```

If you want to check the other options, please refer to the help by using
Expand All @@ -347,7 +347,7 @@ tools/test.py --help
```

> Note: On Windows you should use `python3` executable.
> Example: `python3 tools/test.py test/message`
> Example: `python3 tools/test.py test/report`

You can usually run tests directly with node:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

require('../common');
require('../../common');
const assert = require('assert').strict;

assert.throws(() => { throw new Error('foo'); }, { bar: true });
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
node:assert:*
node:assert*
throw err;
^

Expand All @@ -9,7 +9,7 @@ AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:
- Comparison {
- bar: true
- }
at Object.<anonymous> (*assert_throws_stack.js:*:*)
at *
at *
at *
at *
Expand All @@ -19,16 +19,16 @@ AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:
generatedMessage: true,
code: 'ERR_ASSERTION',
actual: Error: foo
at assert.throws.bar (*assert_throws_stack.js:*)
at getActual (node:assert:*)
at Function.throws (node:assert:*)
at Object.<anonymous> (*assert_throws_stack.js:*:*)
at *
at *
at *
at *
at *
at *,
at *
at *
at *
at *
at node:internal*main*run_main_module**,
expected: { bar: true },
operator: 'throws'
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

// Flags: --expose-internals
require('../common');
require('../../common');

const assert = require('internal/assert');
assert(false);
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
node:internal/assert:*
node:internal*assert*
throw new ERR_INTERNAL_ASSERTION(message);
^

Error [ERR_INTERNAL_ASSERTION]: This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues
Please open an issue with this stack trace at https:**github.com*nodejs*node*issues

at new NodeError (node:internal/errors:*:*)
at assert (node:internal/assert:*:*)
at * (*test*message*internal_assert.js:7:1)
at *
at *
at *
at *
at *
at *
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

// Flags: --expose-internals
require('../common');
require('../../common');

const assert = require('internal/assert');
assert.fail('Unreachable!');
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
node:internal/assert:*
node:internal*assert*
throw new ERR_INTERNAL_ASSERTION(message);
^

Error [ERR_INTERNAL_ASSERTION]: Unreachable!
This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues
Please open an issue with this stack trace at https:**github.com*nodejs*node*issues

at new NodeError (node:internal/errors:*:*)
at Function.fail (node:internal/assert:*:*)
at * (*test*message*internal_assert_fail.js:7:8)
at *
at *
at *
at *
at *
at *
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
require('../common');
require('../../common');
MoLow marked this conversation as resolved.
Show resolved Hide resolved
Error.stackTraceLimit = 3;

const punycode = require('punycode');
Expand Down
10 changes: 10 additions & 0 deletions test/fixtures/console/core_line_numbers.snapshot
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
node:punycode:49
throw new RangeError(errors[type]);
^

RangeError: Invalid input
MoLow marked this conversation as resolved.
Show resolved Hide resolved
at error (node:punycode:49:8)
at Object.decode (node:punycode:*:*)
at Object.<anonymous> (*test*message*core_line_numbers.js:*:*)

Node.js *
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

'use strict';

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

const spawn = require('child_process').spawn;

Expand Down
81 changes: 81 additions & 0 deletions test/fixtures/console/eval_messages.snapshot
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
[eval]
[eval]:1
with(this){__filename}
^^^^
SyntaxError: Strict mode code may not include a with statement
at new Script (node:vm:*:*)
at createScript (node:vm:*:*)
at Object.runInThisContext (node:vm:*:*)
at node:internal/process/execution:*:*
at [eval]-wrapper:*:*
at runScript (node:internal/process/execution:*:*)
at evalScript (node:internal/process/execution:*:*)
at node:internal/main/eval_string:*:*
Comment on lines +6 to +13
Copy link
Member

Choose a reason for hiding this comment

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

This stack trace is a step backward; this test will break if this call path ever changes, which isn’t something that should be breaking a test. Can we eliminate this from the snapshot, perhaps by updating the snapshot generation script if necessary?


Node.js *
42
42
[eval]:1
throw new Error("hello")
^

Error: hello
at [eval]:1:7
at Script.runInThisContext (node:vm:*:*)
at Object.runInThisContext (node:vm:*:*)
at node:internal/process/execution:*:*
at [eval]-wrapper:*:*
at runScript (node:internal/process/execution:*:*)
at evalScript (node:internal/process/execution:*:*)
at node:internal/main/eval_string:*:*

Node.js *

[eval]:1
throw new Error("hello")
^

Error: hello
at [eval]:1:7
at Script.runInThisContext (node:vm:*:*)
at Object.runInThisContext (node:vm:*:*)
at node:internal/process/execution:*:*
at [eval]-wrapper:*:*
at runScript (node:internal/process/execution:*:*)
at evalScript (node:internal/process/execution:*:*)
at node:internal/main/eval_string:*:*

Node.js *
100
[eval]:1
var x = 100; y = x;
^

ReferenceError: y is not defined
at [eval]:1:16
at Script.runInThisContext (node:vm:*:*)
at Object.runInThisContext (node:vm:*:*)
at node:internal/process/execution:*:*
at [eval]-wrapper:*:*
at runScript (node:internal/process/execution:*:*)
at evalScript (node:internal/process/execution:*:*)
at node:internal/main/eval_string:*:*

Node.js *

[eval]:1
var ______________________________________________; throw 10
^
10
(Use `* --trace-uncaught ...` to show where the exception was thrown)

Node.js *

[eval]:1
var ______________________________________________; throw 10
^
10
(Use `* --trace-uncaught ...` to show where the exception was thrown)

Node.js *
done
2 changes: 1 addition & 1 deletion test/fixtures/console/force_colors.snapshot
Original file line number Diff line number Diff line change
@@ -1 +1 @@
123 foo { bar: 'baz' }
123 foo { bar: 'baz' }
2 changes: 1 addition & 1 deletion test/fixtures/console/stack_overflow.snapshot
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
before
*test*fixtures*console*stack_overflow.js:*
at *
JSON.stringify(array);
^

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

'use strict';

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

const spawn = require('child_process').spawn;

Expand Down
89 changes: 89 additions & 0 deletions test/fixtures/console/stdin_messages.snapshot
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
[stdin]
[stdin]:1
with(this){__filename}
^^^^

SyntaxError: Strict mode code may not include a with statement
at new Script (node:vm:*)
at createScript (node:vm:*)
at Object.runInThisContext (node:vm:*)
at node:internal/process/execution:*:*
at [stdin]-wrapper:*:*
at runScript (node:internal/process/execution:*:*)
at evalScript (node:internal/process/execution:*:*)
at node:internal/main/eval_stdin:*:*
at Socket.<anonymous> (node:internal/process/execution:*:*)
at Socket.emit (node:events:*:*)

Node.js *
42
42
[stdin]:1
throw new Error("hello")
^

Error: hello
at [stdin]:1:7
at Script.runInThisContext (node:vm:*)
at Object.runInThisContext (node:vm:*)
at node:internal/process/execution:*:*
at [stdin]-wrapper:*:*
at runScript (node:internal/process/execution:*:*)
at evalScript (node:internal/process/execution:*:*)
at node:internal/main/eval_stdin:*:*
at Socket.<anonymous> (node:internal/process/execution:*:*)
at Socket.emit (node:events:*:*)

Node.js *
[stdin]:1
throw new Error("hello")
^

Error: hello
at [stdin]:1:*
at Script.runInThisContext (node:vm:*)
at Object.runInThisContext (node:vm:*)
at node:internal/process/execution:*:*
at [stdin]-wrapper:*:*
at runScript (node:internal/process/execution:*:*)
at evalScript (node:internal/process/execution:*:*)
at node:internal/main/eval_stdin:*:*
at Socket.<anonymous> (node:internal/process/execution:*:*)
at Socket.emit (node:events:*:*)

Node.js *
100
[stdin]:1
let x = 100; y = x;
^

ReferenceError: y is not defined
at [stdin]:1:16
at Script.runInThisContext (node:vm:*)
at Object.runInThisContext (node:vm:*)
at node:internal/process/execution:*:*
at [stdin]-wrapper:*:*
at runScript (node:internal/process/execution:*:*)
at evalScript (node:internal/process/execution:*:*)
at node:internal/main/eval_stdin:*:*
at Socket.<anonymous> (node:internal/process/execution:*:*)
at Socket.emit (node:events:*:*)

Node.js *

[stdin]:1
let ______________________________________________; throw 10
^
10
(Use `* --trace-uncaught ...` to show where the exception was thrown)

Node.js *

[stdin]:1
let ______________________________________________; throw 10
^
10
(Use `* --trace-uncaught ...` to show where the exception was thrown)

Node.js *
done
14 changes: 7 additions & 7 deletions test/fixtures/errors/force_colors.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ throw new Error('Should include grayed stack trace')
^

Error: Should include grayed stack trace
at Object.<anonymous> (/test*force_colors.js:1:7)
 at Module._compile (node:internal*modules*cjs*loader:1255:14)
 at Module._extensions..js (node:internal*modules*cjs*loader:1309:10)
 at Module.load (node:internal*modules*cjs*loader:1113:32)
 at Module._load (node:internal*modules*cjs*loader:960:12)
 at Function.executeUserEntryPoint [as runMain] (node:internal*modules*run_main:83:12)
 at node:internal*main*run_main_module:23:47
at Object.<anonymous> (*force_colors.js:1:7)
at Module._compile (node:internal*modules*cjs*loader:1255:14)
at Module._extensions..js (node:internal*modules*cjs*loader:1309:10)
at Module.load (node:internal*modules*cjs*loader:1113:32)
at Module._load (node:internal*modules*cjs*loader:960:12)
at Function.executeUserEntryPoint [as runMain] (node:internal*modules*run_main:83:12)
at node:internal*main*run_main_module:23:47

Node.js *
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

require('../common');
require('../../common');
Error.stackTraceLimit = 4;

const assert = require('assert');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ node:assert:*
^

AssertionError [ERR_ASSERTION]: ifError got unwanted exception: test error
at z (*if-error-has-good-stack.js:*:*
at z (*if-error-has-good-stack.js:*:*)
at y (*if-error-has-good-stack.js:*:*)
at x (*if-error-has-good-stack.js:*:*)
at Object.<anonymous> (*if-error-has-good-stack.js:*:*)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Flags: --no-extra-info-on-fatal-exception

'use strict';
require('../common');
require('../../common');
Error.stackTraceLimit = 1;

throw new Error('foo');
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*:7
throw new Error('foo');
^

Error: foo
at Object.<anonymous> (*:7:7)
Loading