test: make eval snapshot comparison more flexible

PR-URL: https://github.com/nodejs/node/pull/57020
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
Shelley Vohr 2025-02-23 20:40:51 +01:00 committed by GitHub
parent 4466e07540
commit ee8939c82f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 4 deletions

View File

@ -40,7 +40,7 @@ Node.js *
var ______________________________________________; throw 10
^
10
(Use `node --trace-uncaught ...` to show where the exception was thrown)
(Use `* --trace-uncaught ...` to show where the exception was thrown)
Node.js *
@ -48,7 +48,7 @@ Node.js *
var ______________________________________________; throw 10
^
10
(Use `node --trace-uncaught ...` to show where the exception was thrown)
(Use `* --trace-uncaught ...` to show where the exception was thrown)
Node.js *
done

View File

@ -40,7 +40,7 @@ Node.js *
let ______________________________________________; throw 10
^
10
(Use `node --trace-uncaught ...` to show where the exception was thrown)
(Use `* --trace-uncaught ...` to show where the exception was thrown)
Node.js *
@ -48,7 +48,7 @@ Node.js *
let ______________________________________________; throw 10
^
10
(Use `node --trace-uncaught ...` to show where the exception was thrown)
(Use `* --trace-uncaught ...` to show where the exception was thrown)
Node.js *
done

View File

@ -1,6 +1,7 @@
import '../common/index.mjs';
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 }, () => {
@ -16,6 +17,7 @@ describe('eval output', { concurrency: true }, () => {
snapshot.replaceNodeVersion,
removeStackTraces,
filterEmptyLines,
generalizeProcessName,
);
function removeStackTraces(output) {
@ -26,6 +28,11 @@ describe('eval output', { concurrency: true }, () => {
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' },