test(cli): don't pin experimental help column padding · Entire
test(cli): don't pin experimental help column padding
55e362c→main·
suhaanthayyil·2d ago·1 file·+23 added/-2 removed
Root help Use/Short spacing shifts with group membership and the longest experimental command name; assert tokens by name+Short instead.
Co-authored-by: Cursor cursoragent@cursor.com
Changes
1
cmd/entire/cli
Mlabs_test.go+23/-2
110 unmodified lines
111
112
113
114
114
115
116
117
118
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
6 unmodified lines
145
146
147
148
149
150
151
152
153
12 unmodified lines
166
167
168
169
170
171
172
173
174
110 unmodified lines
}
// experimentalCommandMarkers are substrings that only appear in root help when
// experimental commands are visible.
// experimental commands are visible. Do not pin cobra's Use/Short column
// padding — group membership and longest-command width shift the spaces.
var experimentalCommandMarkers = []string{
"Experimental commands:",
"review",
"tokens Analyze token usage across sessions and checkpoints",
}
// rootHelpHasTokensCommand reports whether root help lists the experimental
// `tokens` command with its Short description, ignoring Use/Short padding.
func rootHelpHasTokensCommand(got string) bool {
for _, line := range strings.Split(got, "\n") {
fields := strings.Fields(line)
if len(fields) == 0 || fields[0] != "tokens" {
continue
}
if strings.Contains(line, "Analyze token usage across sessions and checkpoints") {
return true
}
}
return false
}
// TestRootHelp_ReleaseHidesExperimental verifies a shipped build
// (experimental.Visible="false") omits experimental commands and the group
// header from root help. Mutates the global gate, so it cannot run in parallel.
6 unmodified lines
t.Fatalf("release root help should not include %q, got:\n%s", marker, got)
}
}
if rootHelpHasTokensCommand(got) {
t.Fatalf("release root help should not list tokens, got:\n%s", got)
}
}
// TestRootHelp_DevShowsExperimentalGroup verifies a developer build
12 unmodified lines
t.Fatalf("dev root help should include %q, got:\n%s", marker, got)
}
}
if !rootHelpHasTokensCommand(got) {
t.Fatalf("dev root help should list tokens with its Short description, got:\n%s", got)
}
}
// summaryColumns returns, for each non-empty rendered row, the rune offset at
Mcmd/entire/cli/labs_test.go+23/-2