Merge pull request 'The Go fetch fails when its shut-off package load cannot run at all, naming the directory and go list's error (issue 1966)' (#655) from fix/1966-shutoff-load-loud into main

This commit was merged in pull request #655.
This commit is contained in:
2026-11-10 15:42:10 +00:00
2 changed files with 13 additions and 1 deletions
@@ -253,6 +253,11 @@ func (m *Module) shutOffLoad(ctx context.Context, env []string, dir, d string) e
if len(lost) > 0 {
return fmt.Errorf("the packages of %s load shut off only with what the fetch did not download: %s", d, strings.Join(lost, "; "))
}
// A load that could not run at all proves nothing: the fetch fails here, not a step later with less to say.
if r.Err != "" || r.Status != 0 {
say := strings.TrimSpace(r.Err + " " + r.Stderr)
return fmt.Errorf("the shut-off package load of %s could not run (exit %d): %s", d, r.Status, say)
}
return nil
}
@@ -215,6 +215,7 @@ func TestAVerifyThatFailsEndsTheStepNamingTheDirectoryAndTheLine(t *testing.T) {
const seatPkg = "git.novox.be/novox/mesh-delivery/contracts/go/seats/nodebuildgo"
for _, c := range []struct {
name, ran, out string
fatal bool
want []string
notWant string
}{
@@ -225,11 +226,17 @@ func TestAVerifyThatFailsEndsTheStepNamingTheDirectoryAndTheLine(t *testing.T) {
{name: "the shut-off package load would reach the network", ran: "tools list -e -deps -test",
out: "fixture/tools/cmd: \n" + seatPkg + ": module lookup disabled by GOPROXY=off\n",
want: []string{"tools", "shut off", seatPkg + ": module lookup disabled by GOPROXY=off"}, notWant: "fixture/tools/cmd"},
// 1966/AC182-1: a package load that could not run at all (a fatal exit, no GOPROXY=off line) fails the fetch too.
{name: "the shut-off package load cannot run", ran: "tools list -e -deps -test", fatal: true,
out: "go: go.mod file not found\n", want: []string{"tools", "go: go.mod file not found"}},
} {
t.Run(c.name, func(t *testing.T) {
f := &fakeStep{gomods: "go.mod\ntools/go.mod\n", goRule: func(line string) forgekey.Ran {
if strings.Contains(line, "/"+c.ran) {
if strings.Contains(line, " list ") {
if c.fatal {
return forgekey.Ran{Status: 1, Stderr: c.out}
}
return forgekey.Ran{Stdout: c.out} // go list -e says a package's error and exits 0
}
return forgekey.Ran{Status: 1, Stdout: c.out}
@@ -249,7 +256,7 @@ func TestAVerifyThatFailsEndsTheStepNamingTheDirectoryAndTheLine(t *testing.T) {
t.Errorf("reason = %q, want it to hold %q", st.Reason, w)
}
}
if strings.Contains(st.Reason, c.notWant) {
if c.notWant != "" && strings.Contains(st.Reason, c.notWant) {
t.Errorf("reason = %q holds %q", st.Reason, c.notWant)
}
if c.ran == "tools list -e -deps -test" {