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 \`<HOME>\` 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.
This commit is contained in:
@@ -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: "<HOME>"]"
|
||||
--cwd working directory [string] [default: "<HOME>"]"
|
||||
`;
|
||||
|
||||
exports[`opencode CLI help-text snapshots every documented command emits stable help text: opencode mcp --help 1`] = `
|
||||
|
||||
@@ -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, "<TMPDIR>")
|
||||
.replaceAll(TMP, "<TMPDIR>")
|
||||
.replace(/<TMPDIR>\/oc-cli-[a-z0-9]+/g, "<HOME>")
|
||||
return (
|
||||
text
|
||||
.replaceAll(REAL_TMP, "<TMPDIR>")
|
||||
.replaceAll(TMP, "<TMPDIR>")
|
||||
.replace(/<TMPDIR>\/oc-cli-[a-z0-9]+/g, "<HOME>")
|
||||
// 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: "<HOME>"\]/g, ' [string] [default: "<HOME>"]')
|
||||
)
|
||||
}
|
||||
|
||||
// Top-level commands. Order matches what `opencode --help` prints today;
|
||||
|
||||
Reference in New Issue
Block a user