From 85e52cf8a34ad25642bfa9c50aea98f6be8c96ea Mon Sep 17 00:00:00 2001 From: Joshua LeMay Date: Sun, 29 Oct 2023 00:55:01 -0500 Subject: [PATCH] test: migrate message v8 tests from Python to JS PR-URL: https://github.com/nodejs/node/pull/50421 Fixes: https://github.com/nodejs/node/issues/47707 Reviewed-By: Moshe Atlow Reviewed-By: Benjamin Gruenbaum Reviewed-By: Yagiz Nizipli Reviewed-By: Geoffrey Booth --- test/{message => fixtures/v8}/v8_warning.js | 2 +- .../v8/v8_warning.snapshot} | 0 test/parallel/test-node-output-v8-warning.mjs | 30 +++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) rename test/{message => fixtures/v8}/v8_warning.js (89%) rename test/{message/v8_warning.out => fixtures/v8/v8_warning.snapshot} (100%) create mode 100644 test/parallel/test-node-output-v8-warning.mjs diff --git a/test/message/v8_warning.js b/test/fixtures/v8/v8_warning.js similarity index 89% rename from test/message/v8_warning.js rename to test/fixtures/v8/v8_warning.js index d7d1c5e7dbdff6..ab4d2bf305823f 100644 --- a/test/message/v8_warning.js +++ b/test/fixtures/v8/v8_warning.js @@ -1,6 +1,6 @@ 'use strict'; -require('../common'); +require('../../common'); function AsmModule() { 'use asm'; diff --git a/test/message/v8_warning.out b/test/fixtures/v8/v8_warning.snapshot similarity index 100% rename from test/message/v8_warning.out rename to test/fixtures/v8/v8_warning.snapshot diff --git a/test/parallel/test-node-output-v8-warning.mjs b/test/parallel/test-node-output-v8-warning.mjs new file mode 100644 index 00000000000000..7278a03ce178e7 --- /dev/null +++ b/test/parallel/test-node-output-v8-warning.mjs @@ -0,0 +1,30 @@ +import '../common/index.mjs'; +import * as fixtures from '../common/fixtures.mjs'; +import * as snapshot from '../common/assertSnapshot.js'; +import { describe, it } from 'node:test'; + +function replaceNodeVersion(str) { + return str.replaceAll(process.version, '*'); +} + +describe('v8 output', { concurrency: true }, () => { + function normalize(str) { + return str.replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '') + .replaceAll(/:\d+/g, ':*') + .replaceAll('/', '*') + .replaceAll('*test*', '*') + .replaceAll('*fixtures*v8*', '*') + .replaceAll('node --', '* --'); + } + const common = snapshot + .transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, replaceNodeVersion); + 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); + }); + } +});