mirror of
https://github.com/hanzoai/babel.git
synced 2026-10-30 14:46:06 +00:00
* test: accept URL in fixture test runner * test: use URL for fixture calls * test: extract systemjs-exec test into single file
49 lines
1.4 KiB
JavaScript
49 lines
1.4 KiB
JavaScript
import {
|
|
buildProcessTests,
|
|
buildParallelProcessTests,
|
|
} from "@babel/helper-transform-fixture-test-runner";
|
|
import path from "node:path";
|
|
import { commonJS } from "$repo-utils";
|
|
|
|
const { __dirname } = commonJS(import.meta.url);
|
|
|
|
const rootDir = path.resolve(__dirname, "../../../..");
|
|
|
|
function escapeRegExp(string) {
|
|
return string.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&");
|
|
}
|
|
|
|
const normalizeOutput = function (str, cwd) {
|
|
let result = str
|
|
.replace(/\(\d+ms\)/g, "(123ms)")
|
|
.replace(new RegExp(escapeRegExp(cwd), "g"), "<CWD>")
|
|
// (non-win32) /foo/babel/packages -> <CWD>/packages
|
|
// (win32) C:\foo\babel\packages -> <CWD>\packages
|
|
.replace(new RegExp(escapeRegExp(rootDir), "g"), "<ROOTDIR>");
|
|
if (process.platform === "win32") {
|
|
result = result
|
|
// C:\\foo\\babel\\packages -> <CWD>\\packages (in js string literal)
|
|
.replace(
|
|
new RegExp(escapeRegExp(rootDir.replace(/\\/g, "\\\\")), "g"),
|
|
"<ROOTDIR>",
|
|
);
|
|
}
|
|
return result;
|
|
};
|
|
|
|
export const runParallel = buildParallelProcessTests(
|
|
"babel-build-external-helpers",
|
|
buildProcessTests(
|
|
new URL("../fixtures", import.meta.url),
|
|
function (test) {
|
|
test.binLoc = path.join(__dirname, "../../lib", test.suiteName);
|
|
},
|
|
function (test, tmpDir, stdout, stderr) {
|
|
return {
|
|
stdout: normalizeOutput(stdout, tmpDir),
|
|
stderr: normalizeOutput(stderr, tmpDir),
|
|
};
|
|
},
|
|
),
|
|
);
|