fix(implementation-sweep): name every missing binary, in flag order

Ranging a map returned at the first failure, so an operator missing three
binaries was told about one, fixed it, reran, and was told about the next.
The function exists to stop the sweep once rather than fail per
implementation and seed.

Two identical runs also printed different errors, which is why this
reached master as a flake instead of a clean red.
This commit is contained in:
pj committed 2026-08-17 23:57:54 +05:30
1 parent 6706461b91
commit 176b495245
2 files changed
+49 -10

No files matched your search

@@ -101,6 +101,37 @@ func TestRunSweep_StopsBeforeItInstallsAnythingWhenABinaryIsMissing(
}
}
// Two binaries missing is one rerun, not two: the operator is told about both
// at once, in flag order, whatever order the check happened to walk.
func TestResolveBinaries_NamesEveryMissingBinaryInFlagOrder(t *testing.T) {
configuration := config{
bunPath: writeScript(
t,
filepath.Join(t.TempDir(), "stub-bun"),
"#!/bin/sh\nexit 0\n",
),
campaignPath: "campaign-that-is-not-installed",
sanderlingPath: "sanderling-that-is-not-installed",
}
err := resolveBinaries(&configuration)
if err == nil {
t.Fatal("got no error, want both missing binaries named")
}
message := err.Error()
campaign := strings.Index(message, "--campaign")
sanderling := strings.Index(message, "--sanderling")
if campaign < 0 || sanderling < 0 {
t.Fatalf("got %q, want both --campaign and --sanderling named", message)
}
if campaign > sanderling {
t.Errorf("got %q, want --campaign named before --sanderling", message)
}
if strings.Contains(message, "--bun") {
t.Errorf("got %q, want the bun that resolved left out", message)
}
}
func TestRunSweep_RefusesADirectoryThatAlreadyHoldsASweep(t *testing.T) {
implementations := t.TempDir()
if err := os.MkdirAll(filepath.Join(implementations, "impl-01"), 0o755); err != nil {