Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 82461af

Browse filesBrowse files
yiyunleimarco-ippolito
authored andcommitted
test: migrate message eval tests from Python to JS
Migrate the eval tests in the `test/message` folder from Python to JS. PR-URL: #50482 Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
1 parent c0d45e7 commit 82461af
Copy full SHA for 82461af

File tree

Expand file treeCollapse file tree

7 files changed

+201
-168
lines changed
Filter options
Expand file treeCollapse file tree

7 files changed

+201
-168
lines changed

‎test/message/eval_messages.js renamed to ‎test/fixtures/eval/eval_messages.js

Copy file name to clipboardExpand all lines: test/fixtures/eval/eval_messages.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
'use strict';
2323

24-
require('../common');
24+
require('../../common');
2525

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

+76Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
[eval]
2+
[eval]:1
3+
with(this){__filename}
4+
^^^^
5+
6+
SyntaxError: Strict mode code may not include a with statement
7+
8+
9+
10+
11+
12+
13+
14+
Node.js *
15+
42
16+
42
17+
[eval]:1
18+
throw new Error("hello")
19+
^
20+
21+
Error: hello
22+
23+
24+
25+
26+
27+
28+
29+
30+
Node.js *
31+
[eval]:1
32+
throw new Error("hello")
33+
^
34+
35+
Error: hello
36+
37+
38+
39+
40+
41+
42+
43+
44+
Node.js *
45+
100
46+
[eval]:1
47+
var x = 100; y = x;
48+
^
49+
50+
ReferenceError: y is not defined
51+
52+
53+
54+
55+
56+
57+
58+
59+
Node.js *
60+
61+
[eval]:1
62+
var ______________________________________________; throw 10
63+
^
64+
10
65+
(Use `node --trace-uncaught ...` to show where the exception was thrown)
66+
67+
Node.js *
68+
69+
[eval]:1
70+
var ______________________________________________; throw 10
71+
^
72+
10
73+
(Use `node --trace-uncaught ...` to show where the exception was thrown)
74+
75+
Node.js *
76+
done

‎test/message/stdin_messages.js renamed to ‎test/fixtures/eval/stdin_messages.js

Copy file name to clipboardExpand all lines: test/fixtures/eval/stdin_messages.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
'use strict';
2323

24-
require('../common');
24+
require('../../common');
2525

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

+89Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
[stdin]
2+
[stdin]:1
3+
with(this){__filename}
4+
^^^^
5+
6+
SyntaxError: Strict mode code may not include a with statement
7+
8+
9+
10+
11+
12+
13+
14+
15+
16+
17+
18+
Node.js *
19+
42
20+
42
21+
[stdin]:1
22+
throw new Error("hello")
23+
^
24+
25+
Error: hello
26+
27+
28+
29+
30+
31+
32+
33+
34+
35+
36+
37+
Node.js *
38+
[stdin]:1
39+
throw new Error("hello")
40+
^
41+
42+
Error: hello
43+
44+
45+
46+
47+
48+
49+
50+
51+
52+
53+
54+
Node.js *
55+
100
56+
[stdin]:1
57+
let x = 100; y = x;
58+
^
59+
60+
ReferenceError: y is not defined
61+
62+
63+
64+
65+
66+
67+
68+
69+
70+
71+
72+
Node.js *
73+
74+
[stdin]:1
75+
let ______________________________________________; throw 10
76+
^
77+
10
78+
(Use `node --trace-uncaught ...` to show where the exception was thrown)
79+
80+
Node.js *
81+
82+
[stdin]:1
83+
let ______________________________________________; throw 10
84+
^
85+
10
86+
(Use `node --trace-uncaught ...` to show where the exception was thrown)
87+
88+
Node.js *
89+
done

‎test/message/eval_messages.out

Copy file name to clipboardExpand all lines: test/message/eval_messages.out
-77Lines changed: 0 additions & 77 deletions
This file was deleted.

‎test/message/stdin_messages.out

Copy file name to clipboardExpand all lines: test/message/stdin_messages.out
-89Lines changed: 0 additions & 89 deletions
This file was deleted.
+34Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import '../common/index.mjs';
2+
import * as fixtures from '../common/fixtures.mjs';
3+
import * as snapshot from '../common/assertSnapshot.js';
4+
import { describe, it } from 'node:test';
5+
6+
describe('eval output', { concurrency: true }, () => {
7+
function normalize(str) {
8+
return str.replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '')
9+
.replaceAll(/\d+:\d+/g, '*:*');
10+
}
11+
12+
const defaultTransform = snapshot.transform(
13+
removeStackTraces,
14+
normalize,
15+
snapshot.replaceWindowsLineEndings,
16+
snapshot.replaceWindowsPaths,
17+
snapshot.replaceNodeVersion
18+
);
19+
20+
function removeStackTraces(output) {
21+
return output.replaceAll(/^ *at .+$/gm, '');
22+
}
23+
24+
const tests = [
25+
{ name: 'eval/eval_messages.js' },
26+
{ name: 'eval/stdin_messages.js' },
27+
];
28+
29+
for (const { name } of tests) {
30+
it(name, async () => {
31+
await snapshot.spawnAndAssert(fixtures.path(name), defaultTransform);
32+
});
33+
}
34+
});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.