From 9f1760e217496b57fa0d6bf42587638d93e33988 Mon Sep 17 00:00:00 2001 From: Doug Mealing Date: Sat, 4 Jul 2026 12:49:16 -0400 Subject: [PATCH] test(cli): generous timeout on --help exit-code tests (cold-start flake) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit help-and-exit.test.ts asserts exit codes, not performance, but ran under bun's default 5s timeout. run() lazily imports each command's (sometimes heavy: migrate-ts, codegen) module on first dispatch, so the first cold-start import on a cold/contended CI runner can exceed 5s and flake the suite — even though the whole file runs in ~115ms once warm. Give these tests a 30s timeout: keeps the exit-code assertions and still fails loudly on a genuine hang, but removes the timing sensitivity. (Surfaced as an intermittent 5001ms failure of 'each subcommand supports --help and exits 0' on the main push path.) Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01Ew1XfYSbEAezxjs9opynAe --- .../packages/cli/test/help-and-exit.test.ts | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/server/typescript/packages/cli/test/help-and-exit.test.ts b/server/typescript/packages/cli/test/help-and-exit.test.ts index ecc9fb8f0..6b6c21d0e 100644 --- a/server/typescript/packages/cli/test/help-and-exit.test.ts +++ b/server/typescript/packages/cli/test/help-and-exit.test.ts @@ -1,30 +1,39 @@ import { test, expect } from "bun:test"; import { run } from "../src/index.js"; +// These assert EXIT CODES (help/usage handling), not performance — so they must +// not be timing-sensitive. `run()` lazily imports each command's (sometimes heavy: +// migrate-ts, codegen) module on first dispatch; on a cold/contended CI runner that +// first cold-start import can exceed bun's default 5s test timeout, flaking the +// suite even though every call returns instantly once warm (~115ms for the whole +// file locally). A generous explicit timeout eliminates that flake while still +// failing loudly on a genuine hang or wrong exit code. +const HELP_TIMEOUT_MS = 30_000; + test("each subcommand supports --help and exits 0", async () => { for (const c of ["gen", "migrate", "verify", "export", "docs", "init"]) { expect(await run([c, "--help"])).toBe(0); } -}); +}, HELP_TIMEOUT_MS); test("each subcommand supports -h and exits 0", async () => { for (const c of ["gen", "verify", "export", "docs", "init"]) { expect(await run([c, "-h"])).toBe(0); } -}); +}, HELP_TIMEOUT_MS); test("prompt-snapshot supports --help and exits 0", async () => { expect(await run(["prompt-snapshot", "--help"])).toBe(0); -}); +}, HELP_TIMEOUT_MS); test("prompt-snapshot supports -h and exits 0", async () => { expect(await run(["prompt-snapshot", "-h"])).toBe(0); -}); +}, HELP_TIMEOUT_MS); test("unknown command exits 2 (usage error)", async () => { expect(await run(["bogus"])).toBe(2); -}); +}, HELP_TIMEOUT_MS); test("bare meta (no args) exits 0", async () => { expect(await run([])).toBe(0); -}); +}, HELP_TIMEOUT_MS);