fix(campaign): name every missing required flag, in flag order

Five required flags ranged as a map, so omitting three told the operator
about one, chosen at random.
This commit is contained in:
pj committed 2026-08-18 00:17:10 +05:30
1 parent ab4c42601d
commit 2fd67d42f9
2 files changed
+46 -8

No files matched your search

+29
View File
@@ -71,6 +71,35 @@ func TestParseArguments_Rejections(t *testing.T) {
}
}
// Three flags missing is one rerun, not three: the operator is told about all
// of them at once, in flag order, whatever order the check happened to walk.
func TestParseArguments_NamesEveryMissingRequiredFlagInFlagOrder(t *testing.T) {
_, err := parseArguments(
[]string{"--bundle-id", "a", "--seeds", "1", "--max-steps", "10"},
io.Discard,
)
if err == nil {
t.Fatal("got no error, want every missing flag named")
}
message := err.Error()
previous := -1
for _, name := range []string{"--spec", "--arm", "--output"} {
at := strings.Index(message, name)
if at < 0 {
t.Fatalf("got %q, want %s named", message, name)
}
if at < previous {
t.Errorf("got %q, want the flags named in flag order", message)
}
previous = at
}
for _, supplied := range []string{"--bundle-id", "--seeds"} {
if strings.Contains(message, supplied) {
t.Errorf("got %q, want the supplied %s left out", message, supplied)
}
}
}
func TestRunArguments_PlatformDeviceFlagAndPassthrough(t *testing.T) {
cases := []struct {
platform string