From bd22c0f5635aaec785e1cbb6fbd31a8412dd5e7e Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Sun, 23 Feb 2025 20:40:51 +0100 Subject: [PATCH] test: make eval snapshot comparison more flexible PR-URL: https://github.com/nodejs/node/pull/57020 Reviewed-By: Luigi Pinca --- test/fixtures/eval/eval_messages.snapshot | 4 ++-- test/fixtures/eval/stdin_messages.snapshot | 4 ++-- test/parallel/test-node-output-eval.mjs | 7 +++++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/test/fixtures/eval/eval_messages.snapshot b/test/fixtures/eval/eval_messages.snapshot index bed16742448..845ff4999be 100644 --- a/test/fixtures/eval/eval_messages.snapshot +++ b/test/fixtures/eval/eval_messages.snapshot @@ -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 diff --git a/test/fixtures/eval/stdin_messages.snapshot b/test/fixtures/eval/stdin_messages.snapshot index 66bd506f758..0382a6ae3cc 100644 --- a/test/fixtures/eval/stdin_messages.snapshot +++ b/test/fixtures/eval/stdin_messages.snapshot @@ -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 diff --git a/test/parallel/test-node-output-eval.mjs b/test/parallel/test-node-output-eval.mjs index d8c52176b1c..8a3cc595742 100644 --- a/test/parallel/test-node-output-eval.mjs +++ b/test/parallel/test-node-output-eval.mjs @@ -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' },