-
-
Notifications
You must be signed in to change notification settings - Fork 35.3k
Expand file tree
/
Copy pathtest-node-output-eval.mjs
More file actions
51 lines (44 loc) · 1.41 KB
/
test-node-output-eval.mjs
File metadata and controls
51 lines (44 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import * as common from '../common/index.mjs';
if (!process.config.variables.node_use_amaro) {
common.skip('Requires Amaro');
}
import * as fixtures from '../common/fixtures.mjs';
import * as snapshot from '../common/assertSnapshot.js';
import { basename } from 'node:path';
import { describe, it } from 'node:test';
describe('eval output', { concurrency: true }, () => {
const normalize = snapshot.transform(
snapshot.transformProjectRoot(''),
(str) => str.replaceAll(/\d+:\d+/g, '*:*'),
);
const defaultTransform = snapshot.transform(
normalize,
snapshot.replaceWindowsLineEndings,
snapshot.replaceWindowsPaths,
snapshot.replaceNodeVersion,
removeStackTraces,
filterEmptyLines,
generalizeProcessName,
);
function removeStackTraces(output) {
return output.replaceAll(/^ *at .+$/gm, '');
}
function filterEmptyLines(output) {
return output.replaceAll(/^\s*$/gm, '');
}
function generalizeProcessName(output) {
const baseName = basename(process.argv0 || 'node', '.exe');
return output.replaceAll(`${baseName} --`, '* --');
}
const tests = [
{ name: 'eval/eval_messages.js' },
{ name: 'eval/stdin_messages.js' },
{ name: 'eval/stdin_typescript.js' },
{ name: 'eval/eval_typescript.js' },
];
for (const { name } of tests) {
it(name, async () => {
await snapshot.spawnAndAssert(fixtures.path(name), defaultTransform);
});
}
});