Files
workinf_Blender_Wasm/tools/web/run-unit-tests.mjs
mes123456 c2c65d3a09
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled
Rebuild local Blender WASM environment and recovery evidence
2026-08-27 20:22:15 +08:00

36 lines
1.3 KiB
JavaScript

import fs from "node:fs";
import path from "node:path";
import { spawnSync } from "node:child_process";
import { fileURLToPath } from "node:url";
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
const testsRoot = path.join(root, "web", "tests");
function collect(directory) {
const files = [];
for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
const file = path.join(directory, entry.name);
if (entry.isDirectory()) files.push(...collect(file));
else if (entry.isFile() && entry.name.endsWith(".test.mjs")) files.push(file);
}
return files.sort();
}
const tests = collect(testsRoot);
for (const [index, file] of tests.entries()) {
const relative = path.relative(path.join(root, "web"), file).replaceAll(path.sep, "/");
process.stdout.write(`unit-file ${index + 1}/${tests.length} ${relative}\n`);
const result = spawnSync(process.execPath, ["--test", "--test-concurrency=1", relative], {
cwd: path.join(root, "web"),
stdio: "inherit",
env: process.env,
});
if (result.status !== 0) {
process.stderr.write(`unit-file-failed ${relative} exit=${result.status ?? 1}\n`);
process.exitCode = result.status ?? 1;
break;
}
}
if (process.exitCode === undefined) process.stdout.write(`unit-suite-ok files=${tests.length}\n`);