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 messages v8 tests from Python to JS #51534

Open
wants to merge 1 commit 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
11 changes: 11 additions & 0 deletions test/fixtures/errors/assert_throws_stack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';

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

assert.throws(
() => {
throw new Error('foo');
},
{ bar: true }
);
36 changes: 36 additions & 0 deletions test/fixtures/errors/assert_throws_stack.snapshot
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
node:assert:*
throw err;
^

AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:
+ actual - expected

+ Comparison {}
- Comparison {
- bar: true
- }
at Object.<anonymous> (*assert_throws_stack.js:*:*)
at Module._compile (node:internal*modules*cjs*loader:*:*)
at Module._extensions..js (node:internal*modules*cjs*loader:*:*)
at Module.load (node:internal*modules*cjs*loader:*:*)
at Module._load (node:internal*modules*cjs*loader:*:*)
at Function.executeUserEntryPoint [as runMain] (node:internal*modules*run_main:*:*)
at node:internal*main*run_main_module:*:* {
Comment on lines +12 to +18
Copy link
Member

Choose a reason for hiding this comment

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

We need to get all of this out of the snapshot, so that changes to the CommonJS loader don’t break tests such as this one. You can use Error.stackTraceLimit = 1 or similar for this (see the similar tests nearby).

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 Module._compile (node:internal*modules*cjs*loader:*:*)
at Module._extensions..js (node:internal*modules*cjs*loader:*:*)
at Module.load (node:internal*modules*cjs*loader:*:*)
at Module._load (node:internal*modules*cjs*loader:*:*)
at Function.executeUserEntryPoint [as runMain] (node:internal*modules*run_main:*:*)
at node:internal*main*run_main_module:*:*,
expected: { bar: true },
operator: 'throws'
}

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

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

console.assert(false, Symbol('hello'));
1 change: 1 addition & 0 deletions test/fixtures/errors/console_assert.snapshot
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Assertion failed Symbol(hello)
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 All @@ -35,17 +35,18 @@ function run(cmd, strict, cb) {
child.on('close', cb);
}

const queue =
[ 'with(this){__filename}',
'42',
'throw new Error("hello")',
'var x = 100; y = x;',
'var ______________________________________________; throw 10' ];
const queue = [
'with(this){__filename}',
'42',
'throw new Error("hello")',
'var x = 100; y = x;',
'var ______________________________________________; throw 10',
];

function go() {
const c = queue.shift();
if (!c) return console.log('done');
run(c, false, function() {
run(c, false, function () {
run(c, true, go);
});
}
Expand Down
76 changes: 76 additions & 0 deletions test/fixtures/errors/eval_messages.snapshot
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
[eval]
[eval]:*
with(this){__filename}
^^^^

SyntaxError: Strict mode code may not include a with statement
at makeContextifyScript (node:internal*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 +7 to +12
Copy link
Member

Choose a reason for hiding this comment

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

Same here and below.


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

Error: hello
at [eval]:*:*
at runScriptInThisContext (node:internal*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]:*
throw new Error("hello")
^

Error: hello
at [eval]:*:*
at runScriptInThisContext (node:internal*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]:*
var x = 100; y = x;
^

ReferenceError: y is not defined
at [eval]:*:*
at runScriptInThisContext (node:internal*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]:*
var ______________________________________________; throw 10
^
10
(Use `node --trace-uncaught ...` to show where the exception was thrown)

Node.js *

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

Node.js *
done
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);
19 changes: 19 additions & 0 deletions test/fixtures/errors/internal_assert.snapshot
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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

at assert (node:internal*assert:*:*)
at Object.<anonymous> (*internal_assert.js:*:*)
at Module._compile (node:internal*modules*cjs*loader:*:*)
at Module._extensions..js (node:internal*modules*cjs*loader:*:*)
at Module.load (node:internal*modules*cjs*loader:*:*)
at Module._load (node:internal*modules*cjs*loader:*:*)
at Function.executeUserEntryPoint [as runMain] (node:internal*modules*run_main:*:*)
at node:internal*main*run_main_module:*:* {
code: 'ERR_INTERNAL_ASSERTION'
}

Node.js *
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!');
20 changes: 20 additions & 0 deletions test/fixtures/errors/internal_assert_fail.snapshot
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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

at Function.fail (node:internal*assert:*:*)
at Object.<anonymous> (*internal_assert_fail.js:*:*)
at Module._compile (node:internal*modules*cjs*loader:*:*)
at Module._extensions..js (node:internal*modules*cjs*loader:*:*)
at Module.load (node:internal*modules*cjs*loader:*:*)
at Module._load (node:internal*modules*cjs*loader:*:*)
at Function.executeUserEntryPoint [as runMain] (node:internal*modules*run_main:*:*)
at node:internal*main*run_main_module:*:* {
code: 'ERR_INTERNAL_ASSERTION'
}

Node.js *
6 changes: 0 additions & 6 deletions test/message/assert_throws_stack.js

This file was deleted.

36 changes: 0 additions & 36 deletions test/message/assert_throws_stack.out

This file was deleted.

1 change: 0 additions & 1 deletion test/message/console_assert.out

This file was deleted.

77 changes: 0 additions & 77 deletions test/message/eval_messages.out

This file was deleted.

19 changes: 0 additions & 19 deletions test/message/internal_assert.out

This file was deleted.

20 changes: 0 additions & 20 deletions test/message/internal_assert_fail.out

This file was deleted.

Loading
Loading