Rebuild local Blender WASM environment and recovery evidence
This commit is contained in:
35
tools/web/run-unit-tests.mjs
Normal file
35
tools/web/run-unit-tests.mjs
Normal file
@@ -0,0 +1,35 @@
|
||||
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`);
|
||||
Reference in New Issue
Block a user