#!/usr/bin/env node /* * runner.mjs — hand-rolled zero-dependency test runner (D-02, D-11). * * Auto-discovers *.test.mjs in this directory (sorted), dynamic-imports * them, and drains the harness registry. A suite that fails to LOAD is * recorded as one failing case — the run never crashes mid-way. * Same hand-rolled shape as theme/scripts/audit.test.mjs (Phase 1) * and bot/test/ (Phase 2) — copied verbatim, workspace-agnostic. */ 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;