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

test/forks.test.ts runs under 10 s #3597

Merged opened this

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

Merged

mason/forge:mason/3579-test-forks-test-ts-runs-under-10-s → main 2 commits fork 1 thread · 1 unresolved

  • Merged. mason/3579-test-forks-test-ts-runs-under-10-s was merged into main as c2ebd0e.

Review

Sign in to review this change.
3 files changed +38 −1
scripts/test-shards.ts +6
@@ -297,6 +297,12 @@ if (tier === "fast") {
297297 );
298298 for (const file of plan.files)
299299 console.log(` ${file}: ${plan.why.get(file)}`);
300 // A diff no test reaches (a timing table, a doc) is judged by the
301 // type check alone: green, not a usage error.
302 if (plan.files.length === 0) {
303 console.log("test-shards: the change reaches no tests; nothing to run");

Exit 0 here is correct for a table or doc-only diff. Beware that a mistyped --diff range with zero changed files also lands here silently; consider printing the changed count (already in the line above, so fine) or exiting non-zero when changed.length is 0.

304 process.exit(0);
305 }
300306 files = plan.files;
301307 }
302308
scripts/test-times.json +1 −1
@@ -37,7 +37,7 @@
3737 "test/feed.test.ts": 8.3,
3838 "test/forge-cloudflare.test.ts": 0.1,
3939 "test/fork-flow.test.ts": 48.4,
40 "test/forks.test.ts": 28.9,
40 "test/forks.test.ts": 1.5,
4141 "test/git-trust.test.ts": 0.3,
4242 "test/helpers.test.ts": 0.7,
4343 "test/landing.test.ts": 9.4,
test/shards.test.ts +31
@@ -667,6 +667,37 @@ describe("the gate audit before any shard", () => {
667667 expect(got.out).toContain("for 1 changed");
668668 expect(got.out).toContain(" test/zz-new.test.ts: changed\n");
669669 }, 30_000);
670
671 test("a pull no test reaches is green with nothing to run, not a usage error (#3579)", async () => {
672 const dir = mkdtempSync(join(tmpdir(), "forge-audit-"));
673 mkdirSync(join(dir, "test"));
674 for (const file of listed) writeFileSync(join(dir, file), "");
675 writeFileSync(join(dir, "impact.json"), JSON.stringify(Object.fromEntries(listed.map((f) => [f, []]))));
676 expect(git(dir, "init", "-q")).toBe(0);
677 expect(git(dir, "add", "-A")).toBe(0);
678 expect(git(dir, "commit", "-qm", "base")).toBe(0);
679 mkdirSync(join(dir, "scripts"));
680 writeFileSync(join(dir, "scripts", "test-times.json"), "{}\n");
681 expect(git(dir, "add", "-A")).toBe(0);
682 expect(git(dir, "commit", "-qm", "a table only")).toBe(0);
683 const child = Bun.spawn(["bun", script, "--tier", "fast", "--diff", "HEAD~1..HEAD"], {
684 cwd: dir,
685 env: { ...process.env, FORGE_CHECK_IMPACT: "impact.json" },
686 stdin: "ignore",
687 stdout: "pipe",
688 stderr: "pipe",
689 });
690 const [out, err] = await Promise.all([
691 new Response(child.stdout).text(),
692 new Response(child.stderr).text(),
693 ]);
694 const code = await child.exited;
695 rmSync(dir, { recursive: true, force: true });
696 expect(out).toContain(`0 of ${gateFiles().length} files for 1 changed`);
697 expect(out).toContain("test-shards: the change reaches no tests; nothing to run");
698 expect(err).not.toContain("name the test files");
699 expect(code).toBe(0);
700 }, 30_000);
670701 });
671702
672703 describe("the gate audit alone, first in the check", () => {

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs