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" #1377

Closed opened this in answer to
Closed without merging

mason/forge:mason/1238-a-new-test-file-joins-the-gate-list-in-t → main 3 commits fork

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
4 files changed +71 −5
CLAUDE.md +4 −2
@@ -84,8 +84,10 @@ bun run src/main.ts # boots on :3000, data in ./data
8484 `bun scripts/test-shards.ts --gate` inside a run: the check on your push is
8585 that same gate, and running both doubles the load on a small machine.
8686 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.
8991 - **Every non-trivial change ships with a test.** Prefer protocol-level tests
9092 that boot a real app (`createApp` + `serve`) over unit mocks. Adversarial
9193 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[] = [
223223 "test/ssh-site.test.ts",
224224 "test/web-code.test.ts",
225225 "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",
226230 ];
227231
228232 export const EXCLUDED: readonly Exclusion[] = [
@@ -368,3 +372,14 @@ export function auditGate(
368372 problems.push(`${file} is in neither GATE nor EXCLUDED`);
369373 return problems;
370374 }
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 @@
3232 */
3333
3434 import { availableParallelism } from "node:os";
35 import { readFileSync, statSync, writeFileSync } from "node:fs";
35 import { readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
3636 import {
3737 formatTimes,
3838 parseShardSpec,
@@ -45,7 +45,7 @@ import {
4545 weigher,
4646 type ShardResult,
4747 } from "./shards.ts";
48 import { GATE } from "./gate.ts";
48 import { auditGate, EXCLUDED, GATE, gateRefusal } from "./gate.ts";
4949 import { fastSet, importsOf, duration } from "../src/checks/tiers.ts";
5050
5151 const TIMES = new URL("./test-times.json", import.meta.url).pathname;
@@ -170,6 +170,21 @@ if (!split.ok) {
170170 process.exit(2);
171171 }
172172 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 }
173188 let files = [...(gate || tier === "fast" ? GATE : []), ...split.files];
174189 if (tier === "fast") {
175190 const diff = Bun.spawnSync(
test/check-list.test.ts +35 −1
@@ -7,7 +7,8 @@
77
88 import { describe, expect, test } from "bun:test";
99 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";
1112
1213 const root = new URL("..", import.meta.url).pathname;
1314 const present = readdirSync(`${root}test`)
@@ -86,3 +87,36 @@ describe("auditGate", () => {
8687 ]);
8788 });
8889 });
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 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs