Public: anyone can read this; the crew can change it.

The gate runs from the base commit's gate script, so a pull cannot loosen the check that judges it #15284

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/15255-the-gate-runs-from-the-base-commit-s-gat → main 0 commits fork 2 threads · 2 unresolved

  • Merged. scout/15255-the-gate-runs-from-the-base-commit-s-gat was merged into main as 17b720c.

Review

Sign in to review this change.
6 files changed +367 −7
docs/features/gate-bypass.md +4 −1
@@ -14,4 +14,7 @@ On 2026-11-01 a bug in the live gate could not be fixed through the gate, and la
1414 The reason (8–500 characters) is written to the pull's trail first, then the pull lands, then `pull.bypassed` goes to the outbox; a refused merge leaves a second comment saying so. Only the checks requirement is skipped; review, conflicts and the agent rule still hold.
1515 - Test: `test/gate-bypass.test.ts`.
1616
17 Not done: running the gate from a pinned earlier release rather than the tree being judged.
17 - **The gate's list is read from the base (#15255).** Before a pull's own check command, the forge writes the base commit's `scripts/gate.ts` into the checkout as `scripts/.gate-base.ts` and runs it with `--base-only` (`checks/base_gate.ts`, `checks/run_tier.ts`). It compares the files the base's gate runs with the ones the pull's gate runs, reading the pull's list without running the pull's code: the base's own `gateFiles` applied to the pull's test files and the `EXCLUDED` its `scripts/gate.ts` names as text (`excludedIn`). A pull whose `EXCLUDED` is not a plain list, or that changes how the list is made (`isLooksFile` through `gateFiles`, `listingCode`), is refused. It refuses every file the pull still has but no longer gates (an `EXCLUDED` entry it added), naming each: `test/x.test.ts is in the base's gate and this pull takes it out of it`. Deleting that refusal from the pull's own `scripts/gate.ts` does not help, since the base's copy runs. A pull that only adds a test file passes and its file is gated the same push. Taking a file out is the owner's to land: an owner pushes the exclusion to the default branch themselves, which no agent can, and the refusal says so. The pull's own gate runs the same comparison, so it is red locally too.
18 - Test: `test/gate-base-list.test.ts`.
19
20 Not done: the shard runner that runs the list (`scripts/test-shards.ts`) is the pull's, so a pull that edits it to skip files is caught only by review; a test file deleted outright is not refused, since that is how two tests fold into one and the diff shows it; a check handed to a runner (`tier_runner.ts`) runs the pull's command without the base step (#15287); the nightly quarantine pull now needs an owner to land it; and the rest of the gate (`gateVerdict`) still runs from the pull's tree, not a pinned earlier release.
scripts/gate.ts +100 −2
@@ -27,9 +27,9 @@
2727 * test that lists the gate's files through it says `@tree-scan` itself.
2828 */
2929
30 import { existsSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
30 import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
3131 import { tmpdir } from "node:os";
32 import { join } from "node:path";
32 import { join, resolve } from "node:path";
3333
3434 export type Exclusion = {
3535 /** Repository-relative path, `test/….test.ts`. */
@@ -478,6 +478,97 @@ export async function pinRefusal(cwd: string = process.cwd()): Promise<string[]>
478478 return [...edits, ...landed, ...missing];
479479 }
480480
481 /**
482 * The files a gate script's `EXCLUDED` names, read as text, never run (#15255): the base's gate
483 * judges a pull without importing the pull's code. Undefined when `EXCLUDED` is not a plain
484 * array literal of `{ file: "…" }` entries, which the base cannot read and so refuses.
485 */
486 export function excludedIn(source: string): string[] | undefined {
487 const at = source.search(/export const EXCLUDED\b[^=]*=\s*\[/);
488 if (at < 0) return undefined;
489 const open = source.indexOf("[", source.indexOf("=", at));
490 let depth = 0;
491 let quote = "";
492 for (let i = open; i < source.length; i++) {
493 const c = source[i];
494 if (quote !== "") {
495 if (c === "\\") i++;
496 else if (c === quote) quote = "";
497 } else if (c === '"' || c === "'" || c === "`") quote = c;
498 else if (c === "[") depth++;
499 else if (c === "]" && --depth === 0) {
500 const list = source.slice(open, i + 1);
501 if (/\.\.\.|\$\{/.test(list)) return undefined;
502 return [...list.matchAll(/\bfile:\s*"([^"\\]+)"/g)].map((m) => m[1]!);
503 }
504 }
505 return undefined;
506 }
507
508 /**
509 * The part of a gate script that turns the test directory and `EXCLUDED` into the list it runs,
510 * `isLooksFile` through `gateFiles`, as text; empty when the script has no such part.
511 */
512 export function listingCode(source: string): string {
513 const from = source.indexOf("export const isLooksFile");
514 const fn = source.indexOf("export function gateFiles(", from);
515 const to = fn < 0 ? -1 : source.indexOf("\n}\n", fn);
516 return from < 0 || to < 0 ? "" : source.slice(from, to + 3);
517 }
518
519 /**
520 * The base's gate list holds (#15255): every file the base commit's gate runs and the pull still
521 * has, the pull's gate runs too. Both lists are read without running the pull's code: the base's
522 * from its own `scripts/gate.ts`, the pull's by applying this file's `gateFiles` to the pull's
523 * test files and the `EXCLUDED` its `scripts/gate.ts` names as text (`excludedIn`); and a pull
524 * that changes how the list is made (`listingCode`) is refused, so the list read here is the one
525 * its gate runs. The forge runs the base's copy of this function before the pull's check
526 * (`src/checks/base_gate.ts`), so deleting it here does not help either. A pull that only adds a
527 * test file passes: the new file is in its own list the same push. A file the pull deletes
528 * outright is not named here: its diff says so, and refusing it would refuse every pull that
529 * folds two tests into one. An update from upstream is not judged again. Taking a file out is the
530 * owner's to land.
531 */
532 export async function baseGateRefusal(cwd: string = process.cwd()): Promise<string[]> {
533 if (!git(["rev-parse", "--git-dir"], cwd).ok) return [];
534 const base = baseRef(cwd);
535 if (!base || isUpdatePull(cwd)) return [];
536 const source = git(["show", `${base}:scripts/gate.ts`], cwd);
537 const listed = git(["ls-tree", "--name-only", base, "--", "test/"], cwd);
538 if (!source.ok || !listed.ok) return [];
539 const owner =
540 "the gate's list is read from the base, so a pull cannot narrow the check that judges it; put it back, or an owner lands it by pushing it to the default branch themselves, which no agent can";
541 const pullPath = join(resolve(cwd), "scripts/gate.ts");
542 const pull = existsSync(pullPath) ? readFileSync(pullPath, "utf8") : "";
543 const excluded = excludedIn(pull);
544 if (excluded === undefined) return [`scripts/gate.ts: its EXCLUDED is not a plain list of { file: "…" } entries the base can read: ${owner}`];
545 const baseListing = listingCode(source.out);
546 if (baseListing !== "" && listingCode(pull) !== baseListing)
547 return [`scripts/gate.ts: this pull changes how the gate's list is made (isLooksFile through gateFiles): ${owner}`];
548 const tree = mkdtempSync(join(process.env.TMPDIR ?? tmpdir(), "gate-base-"));
549 let before: string[];
550 try {
551 mkdirSync(join(tree, "scripts"));
552 mkdirSync(join(tree, "test"));
553 writeFileSync(join(tree, "scripts/gate.ts"), `${source.out}\n`);
554 for (const file of listed.out.split("\n")) {
555 if (/^test\/[^/]+\.test\.ts$/.test(file)) writeFileSync(join(tree, file), "");
556 }
557 before = await treeGate(tree, `base-${base}`);
558 } finally {
559 rmSync(tree, { recursive: true, force: true });
560 }
561 const present = presentTests(cwd);
562 const has = new Set(present);
563 const gated = new Set(gateFiles(present, excluded.map((file) => ({ file, reason: "", issue: 0 }))));
564 const dropped = before.filter((file) => has.has(file) && !gated.has(file));
565 if (dropped.length === 0) return [];
566 return [
567 ...dropped.map((file) => `${file} is in the base's gate and this pull takes it out of it`),
568 `${dropped.join(", ")}: ${owner}`,
569 ];
570 }
571
481572 /**
482573 * A `*.test.ts` under `src/` (vendor excepted) is outside every gate plan,
483574 * since `presentTests` reads only `test/` (#11222): name each, and where it goes.
@@ -862,6 +953,7 @@ export async function gateVerdict(cwd: string = process.cwd()): Promise<{ notes:
862953 const present = presentTests(cwd);
863954 const refusal = [
864955 ...gateRefusal(present),
956 ...(await baseGateRefusal(cwd)),
865957 ...slowRefusal(present),
866958 ...(await pinRefusal(cwd)),
867959 ...(await bothDoorsRefusal(cwd)),
@@ -892,6 +984,12 @@ if (import.meta.main) {
892984 const { writeAllowance, ALLOWANCE_FILE } = await import("./test_honesty.ts");
893985 console.error(`gate: wrote ${ALLOWANCE_FILE} (${writeAllowance(".")} files)`);
894986 }
987 // `--base-only`: the base's copy, which the forge runs before the pull's check (#15255).
988 if (process.argv.includes("--base-only")) {
989 const refused = await baseGateRefusal();
990 for (const line of refused) console.error(`gate: ${line}`);
991 process.exit(refused.length === 0 ? 0 : 2);
992 }
895993 const { notes, refusal } = await gateVerdict();
896994 // Said, never refused: a comment's width stops no check (#12968), nor does the look rule
897995 // (#13362).
src/checks/base_gate.ts added +30
@@ -0,0 +1,30 @@
1 /**
2 * The base commit's gate, run before the pull's own check (#15255): a pull
3 * that edits `scripts/gate.ts` is otherwise judged by its own edited gate.
4 * The forge writes the base's copy into the checkout as `BASE_GATE_FILE`
5 * and runs it with `--base-only`, which compares the gate list the base
6 * names with the one the pull names and refuses every file the pull takes
7 * out (`baseGateRefusal` in `scripts/gate.ts`).
8 *
9 * Only a base whose gate knows the mode is run this way (`BASE_GATE_MARK`):
10 * any other repository's `scripts/gate.ts`, and this one's from before, is
11 * left alone. Plain data in, plain data out: no I/O.
12 */
13
14 /**
15 * Where the forge writes the base's gate in the checkout: beside the pull's, so its imports
16 * resolve.
17 */
18 export const BASE_GATE_FILE = "scripts/.gate-base.ts";
19
20 /** What a base's `scripts/gate.ts` says to be run as the base gate. */
21 export const BASE_GATE_MARK = "export async function baseGateRefusal(";
22
23 /** True when a base's `scripts/gate.ts` source can be run as the base gate. */
24 export const runsAsBaseGate = (source: string | undefined): source is string =>
25 source !== undefined && source.includes(BASE_GATE_MARK);
26
27 /** The check command with the base's gate first; the command unchanged when the base has none. */
28 export function withBaseGate(command: string, source: string | undefined): string {
29 return runsAsBaseGate(source) ? `bun ${BASE_GATE_FILE} --base-only && ${command}` : command;
30 }

The base script this prefixes still imports the pull's gate to get the head list, so a pull that rewrites gateFiles defeats it. Read the head list without executing the pull's code.

src/checks/run_tier.ts +13 −4
@@ -1,7 +1,7 @@
11
22 import { cellHides } from "../spawn/hosted-mark.ts";
33 import { forgeApiKey } from "../crew/runner_env.ts";
4 import { existsSync, mkdirSync } from "node:fs";
4 import { existsSync, mkdirSync, writeFileSync } from "node:fs";
55 import { rm } from "node:fs/promises";
66 import { join } from "node:path";
77 import { noteRunProgress } from "../core/runs.ts";
@@ -19,7 +19,8 @@ import { handoverEnv, handsTimesBack } from "./handover.ts";
1919 import { redDetail } from "./report.ts";
2020 import { rerunFileCommand, rerunRed, withFlaky } from "./rerun.ts";
2121 import { failedFiles, onlyEnv, passedFiles } from "./verify.ts";
22 import { exportTree } from "../apps/checkout.ts";
22 import { exportTree, readFileAt } from "../apps/checkout.ts";
23 import { BASE_GATE_FILE, runsAsBaseGate, withBaseGate } from "./base_gate.ts";
2324 import { childEnv, killedStep, runStep } from "../apps/process.ts";
2425 import { noteReached } from "../apps/egress_report.ts";
2526 import { capacityEnv, checkShardCpus, egressSetting, shardsInForce, shardsLine } from "../core/capacity.ts";
@@ -122,6 +123,14 @@ export async function runTier(lane: LaneState, x: Execution): Promise<CheckOutco
122123 return { ok: false, error: given.error };
123124 }
124125 }
126 // The base's gate runs first (#15255): the pull's own edits to it cannot loosen this step.
127 const baseGate = base === undefined ? undefined : await readFileAt(bare, base, "scripts/gate.ts", 1 << 20);

Wiring untested: add a test through runTier that the check step is prefixed with the base gate and the base file is written from the base commit. Also not applied on the tier_runner path.

128 if (runsAsBaseGate(baseGate)) {
129 mkdirSync(join(dir, "scripts"), { recursive: true });
130 writeFileSync(join(dir, BASE_GATE_FILE), baseGate);
131 write(`gate list: read from ${base!.slice(0, 7)}'s scripts/gate.ts`);
132 }
133 const step = withBaseGate(command, baseGate);
125134 // What the base's own check left (`checks/cache.ts`): tsc's build info
126135 // and the gate's per-file times, keyed by the commit this one builds on.
127136 const cached = restoreCache(
@@ -266,7 +275,7 @@ export async function runTier(lane: LaneState, x: Execution): Promise<CheckOutco
266275 ran = await runJobStep(job, {
267276 runId: run.id,
268277 dir,
269 commands: manifest.install === null ? [command] : [manifest.install, command],
278 commands: manifest.install === null ? [step] : [manifest.install, step],
270279 env,
271280 log: write,
272281 output: checkLines,
@@ -291,7 +300,7 @@ export async function runTier(lane: LaneState, x: Execution): Promise<CheckOutco
291300 // echoes the command as its first line before any output of the
292301 // command's own; that echo is not output to summarise from.
293302 let sawEcho = false;
294 ran = await (options.checkStep ?? runStep)("check", command, {
303 ran = await (options.checkStep ?? runStep)("check", step, {
295304 cwd: dir,
296305 env,
297306 log: (line) => {
test/check-base-gate-step.test.ts added +79
@@ -0,0 +1,79 @@
1 /**
2 * The base's gate runs before the pull's check, through the checks service and the crew
3 * (#15255, `checks/run_tier.ts`): the step the check receives starts with the base gate, and the
4 * file it runs holds the base commit's `scripts/gate.ts`, not the pull's.
5 */
6
7 import { afterAll, beforeAll, describe, expect, test } from "bun:test";
8 import { existsSync, readFileSync } from "node:fs";
9 import { join } from "node:path";
10 import type { App } from "../src/app.ts";
11 import type { User } from "../src/core/users.ts";
12 import { addToCrew } from "../src/actions/crew.ts";
13 import { assignIssue, openIssue } from "../src/actions/issues.ts";
14 import { commitToBranch, createRepo } from "../src/actions/repos.ts";
15 import type { runStep } from "../src/apps/process.ts";
16 import { BASE_GATE_FILE, BASE_GATE_MARK } from "../src/checks/base_gate.ts";
17 import { listRuns } from "../src/core/runs.ts";
18 import { ok } from "../src/kernel/result.ts";
19 import { waitFor } from "./helpers/poll.ts";
20 import { startStandInCrew, stopStandInCrew, type StandInCrew } from "./helpers/crew-standin.ts";
21
22 const BASE_SOURCE = `// the base's gate\n${BASE_GATE_MARK}) { return []; }\n`;
23
24 describe("a pull's check runs the base's gate first, through the service", () => {
25 let standIn: StandInCrew;
26 let app: App;
27 let alice: User;
28 let bot: User;
29 const seen: { command: string; baseFile: string | undefined }[] = [];
30
31 const checkStep: typeof runStep = async (_name, command, options) => {
32 const path = join(options.cwd, BASE_GATE_FILE);
33 seen.push({ command, baseFile: existsSync(path) ? readFileSync(path, "utf8") : undefined });
34 return ok();
35 };
36
37 beforeAll(async () => {
38 standIn = await startStandInCrew({ tickMs: 50, checkStep });
39 ({ app, alice, bot } = standIn);
40 }, 30_000);
41
42 afterAll(() => stopStandInCrew(standIn));
43
44 const until = async <T>(find: () => T | undefined): Promise<T> => {
45 let found: T | undefined;
46 if (!(await waitFor(() => (found = find()) !== undefined, { every: 20, within: 20_000 }))) throw new Error("did not happen in time");
47 return found!;
48 };
49
50 test("the step starts with the base gate, and the base file is the base commit's", async () => {
51 const made = await createRepo(app, alice, { name: "sluice", visibility: "private" });
52 if (!made.ok) throw new Error(String(made.error));
53 const sluice = made.value;
54 const seeded = await commitToBranch(app, alice, sluice, {
55 message: "Start",
56 files: [
57 { path: "README.md", content: "# sluice\n" },
58 { path: "scripts/gate.ts", content: BASE_SOURCE },
59 { path: "forge.json", content: '{"check": {"run": "exit 0", "fast": "true", "install": ""}}\n' },
60 ],
61 });
62 if (!seeded.ok) throw new Error(JSON.stringify(seeded.error));
63 expect(addToCrew(app, alice, sluice, "bot").ok).toBe(true);
64 const issue = openIssue(app, alice, sluice, { title: "Open the sluice", body: "Gently." });
65 if (!issue.ok) throw new Error(String(issue.error));
66 expect(assignIssue(app, alice, sluice, issue.value, bot).ok).toBe(true);
67
68 const built = await until(() =>
69 listRuns(app.db, sluice.id, { kind: "agent", limit: 50 }).find((r) => r.reason === "assigned" && r.state === "ok"),
70 );
71 const pullNumber = Number(built.summary.match(/#(\d+)/)?.[1]);
72 await until(() =>
73 listRuns(app.db, sluice.id, { kind: "check", env: `pull-${pullNumber}`, limit: 50 }).find((r) => r.state === "ok"),
74 );
75 const step = seen.find((s) => s.command.endsWith("true"));
76 expect(step?.command).toBe(`bun ${BASE_GATE_FILE} --base-only && true`);
77 expect(step?.baseFile).toBe(BASE_SOURCE);
78 }, 30_000);
79 });
test/gate-base-list.test.ts added +141
@@ -0,0 +1,141 @@
1 /**
2 * The gate's list is read from the base (#15255): a pull that takes a test file out of the gate
3 * is refused with the file named, even when it also deletes the refusal from its own gate, since
4 * the forge runs the base's copy (`src/checks/base_gate.ts`). A pull that only adds a file passes.
5 */
6 import { afterEach, expect, test } from "bun:test";
7 import { copyFileSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
8 import { tmpdir } from "node:os";
9 import { join } from "node:path";
10 import { BASE_GATE_FILE, withBaseGate } from "../src/checks/base_gate.ts";
11 import { excludedIn } from "../scripts/gate.ts";
12
13 const GATE = join(import.meta.dir, "../scripts/gate.ts");
14 const EMPTY = "export const EXCLUDED: readonly Exclusion[] = [];";
15 const dirs: string[] = [];
16 afterEach(() => {
17 for (const d of dirs.splice(0)) rmSync(d, { recursive: true, force: true });
18 });
19
20 function sh(cwd: string, ...args: string[]): string {
21 const r = Bun.spawnSync(["git", "-c", "user.email=t@t", "-c", "user.name=t", "-c", "commit.gpgsign=false", ...args], { cwd });
22 if (r.exitCode !== 0) throw new Error(r.stderr.toString());
23 return r.stdout.toString().trim();
24 }
25
26 /** A repository whose base commit holds this gate and two test files; `pull` edits the head. */
27 function repo(pull: (dir: string) => void): { dir: string; base: string } {
28 const dir = mkdtempSync(join(tmpdir(), "forge-base-gate-"));
29 dirs.push(dir);
30 sh(dir, "init", "-q", "-b", "trunk");
31 mkdirSync(join(dir, "scripts"));
32 mkdirSync(join(dir, "test"));
33 copyFileSync(GATE, join(dir, "scripts/gate.ts"));
34 writeFileSync(join(dir, "test/a.test.ts"), "");
35 writeFileSync(join(dir, "test/b.test.ts"), "");
36 sh(dir, "add", "-A");
37 sh(dir, "commit", "-qm", "base");
38 const base = sh(dir, "rev-parse", "HEAD");
39 pull(dir);
40 sh(dir, "add", "-A");
41 sh(dir, "commit", "-qm", "pull");
42 // What the forge does before the pull's check: the base's gate beside the pull's.
43 writeFileSync(join(dir, BASE_GATE_FILE), sh(dir, "show", `${base}:scripts/gate.ts`));
44 return { dir, base };
45 }
46
47 function excludeB(dir: string, alsoDeleteRefusal = false): void {
48 const path = join(dir, "scripts/gate.ts");
49 let source = readFileSync(path, "utf8");
50 expect(source).toContain(EMPTY);
51 source = source.replace(
52 EMPTY,
53 'export const EXCLUDED: readonly Exclusion[] = [{ file: "test/b.test.ts", reason: "flaky", issue: 1 }];',
54 );
55 if (alsoDeleteRefusal) {
56 const kept = source;
57 source = source.replace("...(await baseGateRefusal(cwd)),", "");
58 expect(source).not.toBe(kept);
59 }
60 writeFileSync(path, source);
61 }
62
63 function baseGate(dir: string, base: string): { code: number; err: string } {
64 const r = Bun.spawnSync(["bun", BASE_GATE_FILE, "--base-only"], {
65 cwd: dir,
66 env: { ...process.env, FORGE_CHECK_BASE: base },
67 stderr: "pipe",
68 });
69 return { code: r.exitCode, err: r.stderr.toString() };
70 }
71
72 test("a pull that deletes a gate entry is refused by the base's gate, the file named", () => {
73 const { dir, base } = repo((d) => excludeB(d, true));
74 const { code, err } = baseGate(dir, base);
75 expect(code).toBe(2);
76 expect(err).toContain("test/b.test.ts is in the base's gate and this pull takes it out of it");
77 expect(err).toContain("an owner lands it by pushing it to the default branch");
78 expect(err).not.toContain("test/a.test.ts");
79 });
80
81 test("the pull's own gate refuses it too", () => {
82 const { dir, base } = repo((d) => excludeB(d));
83 const r = Bun.spawnSync(["bun", "-e", `const g = await import(${JSON.stringify(join(dir, "scripts/gate.ts"))}); const dir = ${JSON.stringify(dir)}; console.log(JSON.stringify(await g.baseGateRefusal(dir)));`], {
84 cwd: dir,
85 env: { ...process.env, FORGE_CHECK_BASE: base },
86 });
87 const lines = JSON.parse(r.stdout.toString()) as string[];
88 expect(lines[0]).toBe("test/b.test.ts is in the base's gate and this pull takes it out of it");
89 });
90
91 test("a pull that rewrites gateFiles to drop a file, EXCLUDED untouched, is refused without its code being run", () => {
92 const { dir, base } = repo((d) => {
93 const path = join(d, "scripts/gate.ts");
94 const source = readFileSync(path, "utf8");
95 const kept = "return present.filter((file) => !out.has(file));";
96 expect(source).toContain(kept);
97 // Were the pull's gate imported to read its list, this line would make it lie.
98 writeFileSync(path, source.replace(kept, 'return present.filter((file) => !out.has(file) && file !== "test/b.test.ts");'));
99 });
100 const { code, err } = baseGate(dir, base);
101 expect(code).toBe(2);
102 expect(err).toContain("this pull changes how the gate's list is made");
103 });
104
105 test("a pull whose EXCLUDED is not a plain list is refused", () => {
106 const { dir, base } = repo((d) => {
107 const path = join(d, "scripts/gate.ts");
108 writeFileSync(path, readFileSync(path, "utf8").replace(EMPTY, "export const EXCLUDED: readonly Exclusion[] = [...SLOW];"));
109 });
110 const { code, err } = baseGate(dir, base);
111 expect(code).toBe(2);
112 expect(err).toContain("its EXCLUDED is not a plain list");
113 });
114
115 test("EXCLUDED is read as text: entries named, strings with brackets skipped, a computed list unread", () => {
116 expect(excludedIn(EMPTY)).toEqual([]);
117 expect(
118 excludedIn('export const EXCLUDED: readonly Exclusion[] = [\n { file: "test/a.test.ts", reason: "a ] bracket", issue: 1 },\n { file: "test/b.test.ts", reason: `x`, issue: 2 },\n];\nexport const SLOW = [{ file: "test/c.test.ts" }];'),
119 ).toEqual(["test/a.test.ts", "test/b.test.ts"]);
120 expect(excludedIn("export const EXCLUDED = [...more];")).toBeUndefined();
121 expect(excludedIn("export const EXCLUDED = make();")).toBeUndefined();
122 expect(excludedIn("const nothing = 1;")).toBeUndefined();
123 });
124
125 test("a pull that only adds a test file passes, the file gated the same push", () => {
126 const { dir, base } = repo((d) => writeFileSync(join(d, "test/c.test.ts"), ""));
127 expect(baseGate(dir, base)).toEqual({ code: 0, err: "" });
128 });
129
130 // Deleting a file is how two tests fold into one; the diff shows it, and review reads it.
131 test("a pull that deletes a test file outright is not refused here", () => {
132 const { dir, base } = repo((d) => rmSync(join(d, "test/b.test.ts")));
133 expect(baseGate(dir, base).code).toBe(0);
134 });
135
136 test("the check runs the base's gate first only when the base's gate knows the mode", () => {
137 const source = readFileSync(GATE, "utf8");
138 expect(withBaseGate("bun x", source)).toBe(`bun ${BASE_GATE_FILE} --base-only && bun x`);
139 expect(withBaseGate("bun x", "export const GATE = [];")).toBe("bun x");
140 expect(withBaseGate("bun x", undefined)).toBe("bun x");
141 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs