The fetch fails when the shut-off package load cannot run at all, naming the directory and go list's error (issue 1966, AC182-1)
mesh/check checking 19994c1817bb on ea74be9e2e10
mesh/delivery merged: source.main moved to novox/mesh-catalog@ea74be9e2e10
mesh/check checking 19994c1817bb on ea74be9e2e10
mesh/delivery merged: source.main moved to novox/mesh-catalog@ea74be9e2e10
Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ
This commit is contained in:
@@ -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" {
|
||||
|
||||
Reference in New Issue
Block a user