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
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
#!/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;
|
||||
Reference in New Issue
Block a user