Public: anyone can read this; the crew can change it.
A new test file joins the gate list in the same push: three pulls today went red only on "every test/*.test.ts is in exactly one list" #1307
mason/forge:mason/1238-a-new-test-file-joins-the-gate-list-in-t → main 3 commits fork
4 files
changed +71
−5
CLAUDE.md +4 −2
| @@ -84,8 +84,10 @@ bun run src/main.ts # boots on :3000, data in ./data | ||
| 84 | 84 | `bun scripts/test-shards.ts --gate` inside a run: the check on your push is |
| 85 | 85 | that same gate, and running both doubles the load on a small machine. |
| 86 | 86 | It runs the files in `GATE` (`scripts/gate.ts`), not the whole suite; every |
| 87 | other test file is in `EXCLUDED` with its reason and owning issue. Add a new | |
| 88 | test file to `GATE`, or the check goes red. | |
| 87 | other test file is in `EXCLUDED` with its reason and owning issue. A new | |
| 88 | `test/*.test.ts` goes into `GATE` (or `EXCLUDED`, with reason and issue) in | |
| 89 | `scripts/gate.ts` in the same commit: `test/check-list.test.ts` refuses a | |
| 90 | file in neither list, and the gate refuses it before any shard starts. | |
| 89 | 91 | - **Every non-trivial change ships with a test.** Prefer protocol-level tests |
| 90 | 92 | that boot a real app (`createApp` + `serve`) over unit mocks. Adversarial |
| 91 | 93 | tests (can this be bypassed?) are worth more than happy-path ones. |
scripts/gate.ts +15
| @@ -223,6 +223,10 @@ export const GATE: readonly string[] = [ | ||
| 223 | 223 | "test/ssh-site.test.ts", |
| 224 | 224 | "test/web-code.test.ts", |
| 225 | 225 | "test/web-origins.test.ts", |
| 226 | "test/chaos.test.ts", | |
| 227 | "test/fuzz-found.test.ts", | |
| 228 | "test/fuzz-parsers.test.ts", | |
| 229 | "test/health.test.ts", | |
| 226 | 230 | ]; |
| 227 | 231 | |
| 228 | 232 | export const EXCLUDED: readonly Exclusion[] = [ |
| @@ -368,3 +372,14 @@ export function auditGate( | ||
| 368 | 372 | problems.push(`${file} is in neither GATE nor EXCLUDED`); |
| 369 | 373 | return problems; |
| 370 | 374 | } |
| 375 | ||
| 376 | /** | |
| 377 | * The one line `scripts/test-shards.ts` ends on when the list is wrong, so | |
| 378 | * the check's red summary (its output's last line) names the file to add | |
| 379 | * and where, before a shard has started. `undefined` when there is nothing | |
| 380 | * to refuse. | |
| 381 | */ | |
| 382 | export function gateRefusal(problems: readonly string[]): string | undefined { | |
| 383 | if (problems.length === 0) return undefined; | |
| 384 | return `gate list: ${problems.join("; ")} — list every test/*.test.ts in GATE or EXCLUDED in scripts/gate.ts`; | |
| 385 | } |
scripts/test-shards.ts +17 −2
| @@ -32,7 +32,7 @@ | ||
| 32 | 32 | */ |
| 33 | 33 | |
| 34 | 34 | import { availableParallelism } from "node:os"; |
| 35 | import { readFileSync, statSync, writeFileSync } from "node:fs"; | |
| 35 | import { readdirSync, readFileSync, statSync, writeFileSync } from "node:fs"; | |
| 36 | 36 | import { |
| 37 | 37 | formatTimes, |
| 38 | 38 | parseShardSpec, |
| @@ -45,7 +45,7 @@ import { | ||
| 45 | 45 | weigher, |
| 46 | 46 | type ShardResult, |
| 47 | 47 | } from "./shards.ts"; |
| 48 | import { GATE } from "./gate.ts"; | |
| 48 | import { auditGate, EXCLUDED, GATE, gateRefusal } from "./gate.ts"; | |
| 49 | 49 | import { fastSet, importsOf, duration } from "../src/checks/tiers.ts"; |
| 50 | 50 | |
| 51 | 51 | const TIMES = new URL("./test-times.json", import.meta.url).pathname; |
| @@ -170,6 +170,21 @@ if (!split.ok) { | ||
| 170 | 170 | process.exit(2); |
| 171 | 171 | } |
| 172 | 172 | const flags = split.flags; |
| 173 | // The gate's list is audited before a shard starts: a new test file in | |
| 174 | // neither list is refused in milliseconds, by name, not after the whole | |
| 175 | // gate has run and `test/check-list.test.ts` has gone red in it. | |
| 176 | if (gate || tier === "fast") { | |
| 177 | const root = new URL("..", import.meta.url).pathname; | |
| 178 | const present = readdirSync(`${root}test`) | |
| 179 | .filter((name) => name.endsWith(".test.ts")) | |
| 180 | .map((name) => `test/${name}`) | |
| 181 | .sort(); | |
| 182 | const refusal = gateRefusal(auditGate(present, GATE, EXCLUDED)); | |
| 183 | if (refusal !== undefined) { | |
| 184 | console.error(`test-shards: ${refusal}`); | |
| 185 | process.exit(2); | |
| 186 | } | |
| 187 | } | |
| 173 | 188 | let files = [...(gate || tier === "fast" ? GATE : []), ...split.files]; |
| 174 | 189 | if (tier === "fast") { |
| 175 | 190 | const diff = Bun.spawnSync( |
test/check-list.test.ts +35 −1
| @@ -7,7 +7,8 @@ | ||
| 7 | 7 | |
| 8 | 8 | import { describe, expect, test } from "bun:test"; |
| 9 | 9 | import { readdirSync } from "node:fs"; |
| 10 | import { auditGate, EXCLUDED, GATE } from "../scripts/gate.ts"; | |
| 10 | import { auditGate, EXCLUDED, GATE, gateRefusal } from "../scripts/gate.ts"; | |
| 11 | import { summariseCheckFailure } from "../src/checks/summary.ts"; | |
| 11 | 12 | |
| 12 | 13 | const root = new URL("..", import.meta.url).pathname; |
| 13 | 14 | const present = readdirSync(`${root}test`) |
| @@ -86,3 +87,36 @@ describe("auditGate", () => { | ||
| 86 | 87 | ]); |
| 87 | 88 | }); |
| 88 | 89 | }); |
| 90 | ||
| 91 | describe("gateRefusal", () => { | |
| 92 | test("nothing wrong refuses nothing", () => { | |
| 93 | expect(gateRefusal([])).toBeUndefined(); | |
| 94 | }); | |
| 95 | ||
| 96 | test("names every unlisted file and where to list it, on one line", () => { | |
| 97 | const line = gateRefusal( | |
| 98 | auditGate( | |
| 99 | ["test/a.test.ts", "test/new.test.ts", "test/other.test.ts"], | |
| 100 | ["test/a.test.ts"], | |
| 101 | [], | |
| 102 | ), | |
| 103 | )!; | |
| 104 | expect(line).not.toContain("\n"); | |
| 105 | expect(line).toContain("test/new.test.ts is in neither GATE nor EXCLUDED"); | |
| 106 | expect(line).toContain("test/other.test.ts is in neither GATE nor EXCLUDED"); | |
| 107 | expect(line).toContain("scripts/gate.ts"); | |
| 108 | }); | |
| 109 | ||
| 110 | // test-shards.ts --gate prints the refusal last and exits before a shard | |
| 111 | // starts, so the check's red summary is the line that names the file. | |
| 112 | test("is what a refused gate's check summary says", () => { | |
| 113 | const refusal = gateRefusal( | |
| 114 | auditGate(["test/new.test.ts"], [], []), | |
| 115 | )!; | |
| 116 | const { summary } = summariseCheckFailure( | |
| 117 | ["$ tsc --noEmit", `test-shards: ${refusal}`], | |
| 118 | "check exited with code 2", | |
| 119 | ); | |
| 120 | expect(summary).toContain("test/new.test.ts is in neither GATE nor EXCLUDED"); | |
| 121 | }); | |
| 122 | }); |
new above
offline