Skip to content

test: make eval snapshot comparison more flexible #57020

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions test/fixtures/eval/eval_messages.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ 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 *

[eval]:1
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
4 changes: 2 additions & 2 deletions test/fixtures/eval/stdin_messages.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ 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 *

[stdin]:1
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
7 changes: 7 additions & 0 deletions test/parallel/test-node-output-eval.mjs
Original file line number Diff line number Diff line change
@@ -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 }, () => {
Expand All @@ -16,6 +17,7 @@ describe('eval output', { concurrency: true }, () => {
snapshot.replaceNodeVersion,
removeStackTraces,
filterEmptyLines,
generalizeProcessName,
);

function removeStackTraces(output) {
Expand All @@ -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' },
Expand Down
Loading