Files
wehub-resource-sync e4dcfc49aa
Tests / Lint and Format (push) Waiting to run
Tests / Web Node Tests (push) Waiting to run
Tests / Import Check (Python 3.11) (push) Waiting to run
Tests / Import Check (Python 3.12) (push) Waiting to run
Tests / Import Check (Python 3.13) (push) Waiting to run
Tests / Import Check (Python 3.14) (push) Waiting to run
Tests / Python Tests (Python 3.11) (push) Blocked by required conditions
Tests / Python Tests (Python 3.12) (push) Blocked by required conditions
Tests / Python Tests (Python 3.13) (push) Blocked by required conditions
Tests / Python Tests (Python 3.14) (push) Blocked by required conditions
Tests / Test Summary (push) Blocked by required conditions
chore: import upstream snapshot with attribution
2026-07-13 13:00:43 +08:00

55 lines
1.4 KiB
JavaScript

import { readdirSync, rmSync, statSync } from "node:fs";
import { spawnSync } from "node:child_process";
import path from "node:path";
import { fileURLToPath } from "node:url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const webRoot = path.resolve(__dirname, "..");
const distRoot = path.join(webRoot, "dist", "node-tests");
const testRoot = path.join(distRoot, "tests");
function run(cmd, args) {
const result = spawnSync(cmd, args, {
cwd: webRoot,
stdio: "inherit",
env: process.env,
});
if (result.status !== 0) {
process.exit(result.status ?? 1);
}
}
function collectTests(dir) {
const entries = readdirSync(dir)
.map((name) => path.join(dir, name))
.sort((a, b) => a.localeCompare(b));
const files = [];
for (const entry of entries) {
const stats = statSync(entry);
if (stats.isDirectory()) {
files.push(...collectTests(entry));
continue;
}
if (entry.endsWith(".test.js")) {
files.push(entry);
}
}
return files;
}
rmSync(distRoot, { recursive: true, force: true });
run(path.join(webRoot, "node_modules", ".bin", "tsc"), [
"-p",
"tsconfig.node-tests.json",
]);
const testFiles = collectTests(testRoot);
if (testFiles.length === 0) {
console.error("No compiled node tests found.");
process.exit(1);
}
run(process.execPath, ["--test", ...testFiles]);