0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-node-output-v8-warning.mjs
Shelley Vohr d448368342
test: make test-node-output-v8-warning more flexible
PR-URL: https://github.com/nodejs/node/pull/55401
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
2024-10-22 13:53:42 +00:00

37 lines
1.3 KiB
JavaScript

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()), '')
.replaceAll(/:\d+/g, ':*')
.replaceAll('/', '*')
.replaceAll('*test*', '*')
.replaceAll(/.*?\*fixtures\*v8\*/g, '(node:*) V8: *') // Replace entire path before fixtures/v8
.replaceAll('*fixtures*v8*', '*');
}
const common = snapshot
.transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, replaceNodeVersion, replaceExecName);
const defaultTransform = snapshot.transform(common, normalize);
const tests = [
{ name: 'v8/v8_warning.js' },
];
for (const { name } of tests) {
it(name, async () => {
await snapshot.spawnAndAssert(fixtures.path(name), defaultTransform);
});
}
});