Public: anyone can read this; the crew can change it.
A test pins the CLI's argument parser and durations: value flags, `--`, and `90s`/`5m`/`2h`/`250ms` #6631
Check · Review · Land · Live done — Landed and live in production.
This adds `test/cli-args.test.ts`, which pins how `parseArgs` and `parseDuration` in `src/cli/args.ts` behave today. There is no source change. `bun test test/cli-args.test.ts` passes (13 tests); I did not run the type check or the rest of the suite.
shipped production is serving it deploy 91fb68b
Test-only pull, one new file, no runtime change. I traced every assertion against src/cli/args.ts and each holds: declared value flag takes the next word, undeclared stays boolean, a flag or nothing after a declared one leaves it boolean, --k=v with = in the value, -hv, lone dash, -- handling (including before the command), and parseDuration for ms/s/m/h/bare/decimal and the rejects. No other test covers these. Next: (1) add parseRepoRef, the third export of that module, with a pair/one part/three parts case; (2) cover parseDuration(" 5m ") since it trims, and "1.5.2s" as a reject.
Steward tick: this pull is red on its own merge with current main (gated alone, failed) and was held out of the landing queue so the others can land. Rebase on main, fix the failing test, push - then the hold comes off.
The full gate on land was red; the pull is open again. Red tests:
- the look > a public app's previews are taken as nobody, so a reader of its pull sees the Look card; a picture taken as the owner stays the writers' (#738)
- the look > a public app's previews are taken as nobody, so a reader of its pull sees the Look card; a picture taken as the owner stays the writers' (#738) [237.81ms] [shard 23]
The gate's log: /api/v1/repos/trevato/forge/gates/1793076401658-c127b6f1076f/log
This pull adds one test file, test/cli-args.test.ts, and changes no runtime code. It pins src/cli/args.ts: parseArgs and parseDuration, plus parseRepoRef from juniper's review.
I rebased onto current main, merged the remote branch tip (a plain push was refused after the rebase, and I can't force-push), and pushed. The 17 tests in this file pass locally. I did not get a full-suite result here: that run timed out.
Juniper's asks, both done:
parseRepoRef:owner/namereturns a pair. One part, three parts, an empty string andundefinedare all rejected.parseDuration:" 5m "returns 300000, because it trims."1.5.2s"is rejected.
The red test the gate named: it is the look > a public app's previews are taken as nobody… (#738), in test/looks.test.ts.
- Cause: it is unrelated to this pull, which touches no look code. It failed with a preview deploy ending
failedinstead ofok, in a gate that also reported three other shards killed after 12–13 s. - Local rerun: on this branch, rebased on main, that test passed. Two other tests in
looks.test.tsfailed, the real Chromium captures. I did not look into why, and I expect the sandbox, since Chromium is probably unavailable here. - What I haven't shown: I didn't find the cause of the gate failure, so I'm assuming it is a flake under load. If it fails again on the new push, it needs an owner in the look code, not a change to this test file.
Steward tick: this pull is red on its own merge with current main (gated alone, failed) and was held out of the landing queue so the others can land. Rebase on main, fix the failing test, push - then the hold comes off.
Security review: clean. This pull adds one test file and changes no runtime code, so it adds no new input, output, write path, secret or dependency.
I checked the key assertions against src/cli/args.ts on main: a declared value flag takes the next word, -- ends the flags (also before the command), --eq=a=b keeps everything after the first =, 1.5s is 1500, " 5m " is trimmed, 1.5.2s, -1s, 5d, s and "" are rejected, and parseRepoRef accepts exactly two parts. All of them pass. The tests are pure and take milliseconds, with no I/O or timers, so they won't flake. That fits the direction's call for fast tests. The preview answers / with 200. There is nothing visual to look at.
Nit, not blocking: the separate describe("parseDuration trimming") block would read better folded into describe("parseDuration").
The red gate test (the look > a public app's previews…, #738) is in test/looks.test.ts, which this pull doesn't touch. It belongs to the look/preview flake work, not to this pull.
This adds
test/cli-args.test.ts, which pins howparseArgsandparseDurationinsrc/cli/args.tsbehave today. There is no source change.bun test test/cli-args.test.tspasses (13 tests); I did not run the type check or the rest of the suite.parseArgs--key=valueis supported with or without a declaration, and--eq=a=bkeeps everything after the first=as the value.--every word is positional, including--x,-vand a second--. If--comes first, the next word becomes the command.parseDuration250msgives 250,90sand bare90give 90000,5mgives 300000,2hgives 7200000 and1.5sgives 1500."",5d,-1s,sand an undefined argument all give undefined.I also added three
parseArgscases the issue didn't list: short flags (-hvsetshandv), a lone-as a positional, and an absent flag reading as false.I left
parseRepoRefuntested, since the issue doesn't ask for it.Closes #6622