test: hold hand-written CLI help to a baseline that may only shrink #863
No reviewers
Labels
No labels
breaking
bug
documentation
enhancement
epic
good first issue
help wanted
refactoring
resolution/duplicate
resolution/invalid
resolution/wontfix
security
severity/critical
severity/high
severity/low
severity/medium
status/abandoned
status/blocked
status/needs-decision
status/needs-info
status/needs-verification
testing
upstream
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
sixfold-space/madtea!863
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "issue-515-opspec-help-ratchet"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
What was wrong
ADR 0008 moves CLI help into the
internal/opspecregistry. Almost no command uses it. Nothing stops a new command from adding more hand-writtenLong:help.What changed
internal/cmdutil/clispec.go:ApplyCLISpecnow keeps a copy of theShortandLongtext it renders in two command annotations. It clones theAnnotationsmap first. Commands that share one map (for example theadrcommands) no longer replace each other's record.internal/cmdutil/clispec.go: newHelpFromSpecreports whether a command'sShortandLongare still the rendered text. It returns false for hand-written help, for text written over the rendered text, and for an emptyLong.internal/cmd/handwritten_help_test.go: newTestHandwrittenHelpBaselinewalks the command tree fromRootCmd. It lists every runnable command whose help does not render from opspec. Command groups with noRunare not counted, and neither is thehelpcommand that Cobra adds.internal/cmd/testdata/handwritten_help.golden: the checked-in baseline, with 542 commands.docs/contributing/adding-commands.md: the add-a-command checklist now says to render help withcmdutil.ApplyCLISpecand names the baseline test.The test fails in three cases:
cmdutil.ApplyCLISpec.-update.Running the test with
-updaterewrites the file. It refuses to add a line, so the baseline can only shrink.Tests
TestHelpFromSpecandTestHelpFromSpecShortOverwrittenininternal/cmdutil/clispec_test.gocover rendered, hand-written, overwrittenLong, overwrittenShort, and empty help.TestApplyCLISpecSharedAnnotationscovers two commands that share oneAnnotationsmap. It checks that each keeps its own record, that the shared map is unchanged, and that existing annotations stay.TestHandwrittenHelpNewCommandFailschecks that a new hand-written command fails and that-updaterefuses to add it.TestHandwrittenHelpMigrationShrinksBaselinechecks that a migrated command leaves a stale line, and that-updateremoves it.TestHandwrittenHelpOverwrittenLongFailschecks that aLongwritten over rendered help counts as hand-written.Not in this change
The issue also asks for an epic with one child per noun. This change does not add it. Refs #515
./scripts/gate.shpasses on this commit.Refs #515