From a8734e98c7fe8ff36aa49c1337360b0f3a1eaf8a Mon Sep 17 00:00:00 2001 From: sim Date: Sun, 18 Oct 2026 10:07:16 +0000 Subject: [PATCH] tests: run every check file in tests/ npm test now runs tests/run.mjs, which runs each tests/*.mjs in turn and fails if any of them fails. A study can keep its checks in its own file instead of appending to tests/checks.mjs, the end of which every open research PR currently edits. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01C2bpiHyHSkC8DAL5CcyciK --- package.json | 2 +- tests/run.mjs | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 tests/run.mjs diff --git a/package.json b/package.json index 712db39..1bbc3a0 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Self-similarity across scales, tested with first principles. First study: the Witness Map.", "license": "Apache-2.0", "scripts": { - "test": "node tests/checks.mjs", + "test": "node tests/run.mjs", "table": "node witness-map/table.mjs" } } diff --git a/tests/run.mjs b/tests/run.mjs new file mode 100644 index 0000000..7a8f0a2 --- /dev/null +++ b/tests/run.mjs @@ -0,0 +1,17 @@ +// Runs every check file in tests/ and fails if any of them fails. Run: npm test (or node tests/run.mjs). +// Each study keeps its checks in its own file here, so studies developed in parallel do not edit the same file. +import { readdirSync } from 'node:fs'; +import { spawnSync } from 'node:child_process'; +import { fileURLToPath } from 'node:url'; +import path from 'node:path'; + +const dir = path.dirname(fileURLToPath(import.meta.url)); +const files = readdirSync(dir).filter(f => f.endsWith('.mjs') && f !== 'run.mjs').sort(); +const failed = []; +for (const f of files) { + console.log(`\n== ${f}\n`); + const r = spawnSync(process.execPath, [path.join(dir, f)], { stdio: 'inherit' }); + if (r.status !== 0) failed.push(f); +} +console.log(failed.length ? `\nfailed: ${failed.join(', ')}` : `\nall ${files.length} check file(s) pass`); +process.exit(failed.length ? 1 : 0);