From d448368342cae946c46874b5af1321220925ed97 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Tue, 22 Oct 2024 15:53:42 +0200 Subject: [PATCH] test: make test-node-output-v8-warning more flexible PR-URL: https://github.com/nodejs/node/pull/55401 Reviewed-By: Luigi Pinca Reviewed-By: Richard Lau --- test/parallel/test-node-output-v8-warning.mjs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-node-output-v8-warning.mjs b/test/parallel/test-node-output-v8-warning.mjs index 309e904c49b..b5e52d493ba 100644 --- a/test/parallel/test-node-output-v8-warning.mjs +++ b/test/parallel/test-node-output-v8-warning.mjs @@ -2,11 +2,17 @@ import '../common/index.mjs'; import * as fixtures from '../common/fixtures.mjs'; import * as snapshot from '../common/assertSnapshot.js'; import { describe, it } from 'node:test'; +import { basename } from 'node:path'; function replaceNodeVersion(str) { return str.replaceAll(process.version, '*'); } +function replaceExecName(str) { + const baseName = basename(process.argv0 || 'node', '.exe'); + return str.replaceAll(`${baseName} --`, '* --'); +} + describe('v8 output', { concurrency: !process.env.TEST_PARALLEL }, () => { function normalize(str) { return str.replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '') @@ -14,11 +20,10 @@ describe('v8 output', { concurrency: !process.env.TEST_PARALLEL }, () => { .replaceAll('/', '*') .replaceAll('*test*', '*') .replaceAll(/.*?\*fixtures\*v8\*/g, '(node:*) V8: *') // Replace entire path before fixtures/v8 - .replaceAll('*fixtures*v8*', '*') - .replaceAll('node --', '* --'); + .replaceAll('*fixtures*v8*', '*'); } const common = snapshot - .transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, replaceNodeVersion); + .transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, replaceNodeVersion, replaceExecName); const defaultTransform = snapshot.transform(common, normalize); const tests = [ { name: 'v8/v8_warning.js' },