From af1e67d850cb7c4f5446a573e5cb932cb3d6d286 Mon Sep 17 00:00:00 2001 From: Kit Langton Date: Mon, 18 May 2026 21:22:59 -0400 Subject: [PATCH] test(cli): stabilize acp --help snapshot against random home path length yargs wraps the \`[string] [default: "..."]\` clause based on the pre-normalized default value's character length, so a different random tmpdir width produces a different leading-whitespace count on the wrapped continuation line. After normalizing the path to \`\` we were left with a one-space drift between runs. Collapse the wrap-dependent whitespace immediately before the clause so the snapshot is byte-stable regardless of home path length. Verified by deleting the .snap and regenerating across 3 runs. --- .../__snapshots__/help-snapshots.test.ts.snap | 3 +-- .../opencode/test/cli/help/help-snapshots.test.ts | 15 +++++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/opencode/test/cli/help/__snapshots__/help-snapshots.test.ts.snap b/packages/opencode/test/cli/help/__snapshots__/help-snapshots.test.ts.snap index 243f49b60b..22ad59aaa2 100644 --- a/packages/opencode/test/cli/help/__snapshots__/help-snapshots.test.ts.snap +++ b/packages/opencode/test/cli/help/__snapshots__/help-snapshots.test.ts.snap @@ -18,8 +18,7 @@ Options: --mdns-domain custom domain name for mDNS service (default: opencode.local) [string] [default: "opencode.local"] --cors additional domains to allow for CORS [array] [default: []] - --cwd working directory - [string] [default: ""]" + --cwd working directory [string] [default: ""]" `; exports[`opencode CLI help-text snapshots every documented command emits stable help text: opencode mcp --help 1`] = ` diff --git a/packages/opencode/test/cli/help/help-snapshots.test.ts b/packages/opencode/test/cli/help/help-snapshots.test.ts index 08b4c40438..30404b156b 100644 --- a/packages/opencode/test/cli/help/help-snapshots.test.ts +++ b/packages/opencode/test/cli/help/help-snapshots.test.ts @@ -27,10 +27,17 @@ import { cliIt } from "../../lib/cli-process" const TMP = os.tmpdir() const REAL_TMP = fs.realpathSync(TMP) function normalize(text: string): string { - return text - .replaceAll(REAL_TMP, "") - .replaceAll(TMP, "") - .replace(/\/oc-cli-[a-z0-9]+/g, "") + return ( + text + .replaceAll(REAL_TMP, "") + .replaceAll(TMP, "") + .replace(/\/oc-cli-[a-z0-9]+/g, "") + // yargs wraps the `[string] [default: "..."]` clause based on the + // pre-normalized default's character length, so different random home + // path widths produce different leading-whitespace counts on the + // wrapped continuation. Collapse the wrap-dependent whitespace. + .replace(/\s+\[string\] \[default: ""\]/g, ' [string] [default: ""]') + ) } // Top-level commands. Order matches what `opencode --help` prints today;