Skip to content

Commit ee8939c

Browse files
authored
test: make eval snapshot comparison more flexible
PR-URL: #57020 Reviewed-By: Luigi Pinca <[email protected]>
1 parent 4466e07 commit ee8939c

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

test/fixtures/eval/eval_messages.snapshot

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ Node.js *
4040
var ______________________________________________; throw 10
4141
^
4242
10
43-
(Use `node --trace-uncaught ...` to show where the exception was thrown)
43+
(Use `* --trace-uncaught ...` to show where the exception was thrown)
4444

4545
Node.js *
4646

4747
[eval]:1
4848
var ______________________________________________; throw 10
4949
^
5050
10
51-
(Use `node --trace-uncaught ...` to show where the exception was thrown)
51+
(Use `* --trace-uncaught ...` to show where the exception was thrown)
5252

5353
Node.js *
5454
done

test/fixtures/eval/stdin_messages.snapshot

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ Node.js *
4040
let ______________________________________________; throw 10
4141
^
4242
10
43-
(Use `node --trace-uncaught ...` to show where the exception was thrown)
43+
(Use `* --trace-uncaught ...` to show where the exception was thrown)
4444

4545
Node.js *
4646

4747
[stdin]:1
4848
let ______________________________________________; throw 10
4949
^
5050
10
51-
(Use `node --trace-uncaught ...` to show where the exception was thrown)
51+
(Use `* --trace-uncaught ...` to show where the exception was thrown)
5252

5353
Node.js *
5454
done

test/parallel/test-node-output-eval.mjs

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import '../common/index.mjs';
22
import * as fixtures from '../common/fixtures.mjs';
33
import * as snapshot from '../common/assertSnapshot.js';
4+
import { basename } from 'node:path';
45
import { describe, it } from 'node:test';
56

67
describe('eval output', { concurrency: true }, () => {
@@ -16,6 +17,7 @@ describe('eval output', { concurrency: true }, () => {
1617
snapshot.replaceNodeVersion,
1718
removeStackTraces,
1819
filterEmptyLines,
20+
generalizeProcessName,
1921
);
2022

2123
function removeStackTraces(output) {
@@ -26,6 +28,11 @@ describe('eval output', { concurrency: true }, () => {
2628
return output.replaceAll(/^\s*$/gm, '');
2729
}
2830

31+
function generalizeProcessName(output) {
32+
const baseName = basename(process.argv0 || 'node', '.exe');
33+
return output.replaceAll(`${baseName} --`, '* --');
34+
}
35+
2936
const tests = [
3037
{ name: 'eval/eval_messages.js' },
3138
{ name: 'eval/stdin_messages.js' },

0 commit comments

Comments
 (0)