Repository navigation
Pin what a program prints with golden files - #75
Merged
Merged
Conversation
assertSurface(root) renders a command tree, so it can't show what a Program adds: the argument-file line in help, the @* case in completion scripts, or the configuration it reads. assertSurface(program) runs the program and compares what it printed. Program.root becomes public so the testing module can walk the commands. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
aoreshkov
added a commit
that referenced
this pull request
Nov 6, 2026
## Summary `completion <shell>` uses no option's value, but three things from the commands above it could stop it: - a required option: `demo completion bash` exits 2 with `missing required option --store` - an invalid value in an inherited option's variable - a constraint on a parent command, such as `ExactlyOne` The parser already skipped settings for this command, so a broken configuration file couldn't stop it. It now returns right after reading the command's own command line, which covers all three and the settings with one check. `Program` was already answering `completion` without a handler. `completion` is still held to its own command line: a missing or unknown shell is a usage error, and so is an invalid value typed on it. Other commands are held to everything as before. There's no public API change. ## Testing - `ProgramTest`: the new test covers all three cases and failed before the fix with `missing required option --store`. It also checks that `go` on the same programs still exits with a usage error. A second test covers `completion`'s own command line. - `./gradlew check` is green on Windows. The bash completion and SIGTERM tests are skipped there, so they need this PR's Linux job. - This PR and #75 touch nearby lines. A trial merge of the two has no conflicts and passes `:cli-kit:check` and `:cli-kit-testing:check`, again on Windows only. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GoldenFiles.assertSurface(root)renders a command tree, so it can't show what aProgramadds: the argument-file line in help, the@*case in completion scripts, or the configuration it reads without passingsettingsagain. A program with argument files on had no public way to pin what it really prints.GoldenFiles.assertSurface(program)runs the program instead, with--helpat each command andcompletion <shell>, and compares what it printed.Program.rootbecomes public so the testing module can walk the commands.assertSurface(root)stays, for a test with no program to run. With argument files off, both forms read the same files.StandardOptions.completiongets no script files, because it never prints any. The tree form still writes them.The ABI dumps change by additions only.
Testing
./gradlew checkis green on Windows. The bash completion and SIGTERM tests are skipped there, so they need this PR's Linux job.GoldenFilesTestcases: the two forms read the same files; argument files show in a program's files and fail the tree form; settings show with nothing more to pass; no completion command means no scripts, and a leftover one is an orphan; a page the program won't print fails by name.assertSurface(DelvaProgram.program)and built with-Pdelva.cliKitFromSource=truepassed against its existing golden files unchanged. delva-cli can move to the new call once its pin reaches 0.5.0.🤖 Generated with Claude Code