// The M3 acceptance checklist as a test: the nine groups of DESIGN 13 exist, each points at a real // harness in tools/, and each carries the exact test that proves it (DESIGN 14, #12 / #25). #36: // "proves it" is not a substring — the declaration and its body must still hold the assertions and // the call the group claims, and `tools/test.sh` separately requires the reporter to show every one // of these tests passing (tools/evidence.mjs), so a hollowed or unrun test cannot count. import test from 'node:test' import assert from 'node:assert/strict' import fs from 'node:fs' import path from 'node:path' import { GROUP_COUNT, GROUPS } from './groups.mjs' import { findTestBody } from './evidence.mjs' import { projectRoot } from './lib.mjs' const tools = path.join(projectRoot, 'tools') test('M3 accept: the nine groups of DESIGN 13 are mapped to named harness tests', () => { assert.deepEqual(Object.keys(GROUPS), [ 'leak+fault', 'tiles', 'probing', 'protocol', 'auth', 'characters and names', 'restart', 'persistence', 'logs', ], 'the group names are the ones of DESIGN 13 (FIXED #12)') assert.equal(Object.keys(GROUPS).length, GROUP_COUNT) for (const [group, spec] of Object.entries(GROUPS)) { for (const file of spec.files) { const full = path.join(tools, file) assert.ok(fs.existsSync(full), `${group}: ${file} exists`) assert.ok(fs.statSync(full).size > 0, `${group}: ${file} is not empty`) } assert.ok(spec.evidence.length >= 1, `${group}: names its proving test`) for (const ev of spec.evidence) { assert.ok(spec.files.includes(ev.file), `${group}: evidence file ${ev.file} is one of the group files`) assert.equal(typeof ev.test, 'string', `${group}: evidence names an exact test title`) assert.ok(!ev.test.includes('*'), `${group}: the evidence title is exact, not a glob`) const text = fs.readFileSync(path.join(tools, ev.file), 'utf8') const found = findTestBody(text, ev.test) assert.ok(found, `${group}: ${ev.file} declares exactly one test with the title "${ev.test}" ` + '(a renamed, duplicated or absent evidence test fails the group)') const asserts = (found.body.match(/\bassert\.[A-Za-z]+/g) ?? []).length const min = ev.minAsserts ?? 1 assert.ok(asserts >= min, `${group}: "${ev.test}" keeps its assertions (${asserts} found, at least ${min} required)`) for (const needle of ev.requires ?? []) { assert.ok(found.body.includes(needle), `${group}: "${ev.test}" still executes \`${needle}\``) } } } // Every *group* harness is run by `tools/test.sh` (one glob over tools/*.test.mjs). const globbed = fs.readdirSync(tools).filter(f => f.endsWith('.test.mjs')) for (const spec of Object.values(GROUPS)) { for (const file of spec.files) assert.ok(globbed.includes(file), `${file} is run by devbox run test`) } })