Files
arah2/routing/test/runner.mjs
T
araharah-executor 69b6a20350 test(05-01): scaffold routing workspace with failing contract suite
- fifth npm workspace @araharah/routing (buildless TS, search/ precedent)
- root delegates routing:test / routing:typecheck / routing:corpus
- C1-C6 RED: contract gates fail while src/types.ts + seed are absent
2026-10-24 04:59:17 +08:00

49 lines
1.3 KiB
JavaScript

#!/usr/bin/env node
/*
* runner.mjs — hand-rolled zero-dependency test runner.
*
* Same shape as bot/test/runner.mjs (the Phase 2 precedent):
* - Auto-discovers *.test.mjs in this directory (sorted) and dynamic-imports them.
* - A suite that fails to LOAD is recorded as one failing case
* ("suite load failed: <file>") — the run never crashes mid-way.
* - Per case: PASS <name> / FAIL <name> (+ error detail).
* - Summary line + exit codes: exit 0 only when every case passed.
*/
import { readdirSync } from "node:fs";
import { registry } from "./harness.mjs";
const dir = import.meta.dirname;
const suites = readdirSync(dir)
.filter((f) => f.endsWith(".test.mjs"))
.sort();
for (const file of suites) {
try {
await import(`./${file}`);
} catch (loadErr) {
registry.push({
name: `suite load failed: ${file}`,
fn: () => {
throw loadErr;
},
});
}
}
let passedCount = 0;
let failedCount = 0;
for (const { name, fn } of registry) {
try {
await fn();
passedCount++;
console.log(`PASS ${name}`);
} catch (err) {
failedCount++;
console.log(`FAIL ${name}`);
console.error(` ${err && err.stack ? err.stack : String(err)}`);
}
}
console.log(`[runner] ${passedCount} passed, ${failedCount} failed`);
process.exitCode = failedCount > 0 ? 1 : 0;