From: Austin Clements Date: Tue, 17 Oct 2023 21:21:47 +0000 (-0400) Subject: cmd/go: track root failing Action X-Git-Tag: go1.24rc1~356 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=9060fa5afd52fcdb60c09e26c73f5980520ca9f9;p=gostls13.git cmd/go: track root failing Action Currently, each Action tracks whether it failed, which is propagated up from dependencies. Shortly, we'll need to know the root cause if a test fails because of a build failure. To support this, replace the Failed boolean with a Failed *Action that tracks the root Action that failed and caused other Actions to fail. For #62067. Change-Id: I8f84a51067354043ae9531a4368c6f8b11d688d5 Reviewed-on: https://go-review.googlesource.com/c/go/+/536398 Reviewed-by: Russ Cox LUCI-TryBot-Result: Go LUCI --- diff --git a/src/cmd/go/internal/test/test.go b/src/cmd/go/internal/test/test.go index 2a83890a33..93e0137481 100644 --- a/src/cmd/go/internal/test/test.go +++ b/src/cmd/go/internal/test/test.go @@ -1387,9 +1387,9 @@ func (r *runTestActor) Act(b *work.Builder, ctx context.Context, a *work.Action) // Release next test to start (test2json.NewConverter writes the start event). close(r.next) - if a.Failed { + if a.Failed != nil { // We were unable to build the binary. - a.Failed = false + a.Failed = nil fmt.Fprintf(stdout, "FAIL\t%s [build failed]\n", a.Package.ImportPath) // Tell the JSON converter that this was a failure, not a passing run. err = errors.New("build failed") diff --git a/src/cmd/go/internal/work/action.go b/src/cmd/go/internal/work/action.go index 7567284d70..ab577a6e0e 100644 --- a/src/cmd/go/internal/work/action.go +++ b/src/cmd/go/internal/work/action.go @@ -110,7 +110,7 @@ type Action struct { // Execution state. pending int // number of deps yet to complete priority int // relative execution priority - Failed bool // whether the action failed + Failed *Action // set to root cause if the action failed json *actionJSON // action graph information nonGoOverlay map[string]string // map from non-.go source files to copied files in objdir. Nil if no overlay is used. traceSpan *trace.Span @@ -218,7 +218,7 @@ func actionGraphJSON(a *Action) string { Args: a.Args, Objdir: a.Objdir, Target: a.Target, - Failed: a.Failed, + Failed: a.Failed != nil, Priority: a.priority, Built: a.built, VetxOnly: a.VetxOnly, diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go index 1aaf50f1fb..6fed8d9cbc 100644 --- a/src/cmd/go/internal/work/exec.go +++ b/src/cmd/go/internal/work/exec.go @@ -138,7 +138,7 @@ func (b *Builder) Do(ctx context.Context, root *Action) { a.json.TimeStart = time.Now() } var err error - if a.Actor != nil && (!a.Failed || a.IgnoreFail) { + if a.Actor != nil && (a.Failed == nil || a.IgnoreFail) { // TODO(matloob): Better action descriptions desc := "Executing action (" + a.Mode if a.Package != nil { @@ -176,12 +176,14 @@ func (b *Builder) Do(ctx context.Context, root *Action) { sh := b.Shell(a) sh.Errorf("%s", err) } - a.Failed = true + if a.Failed == nil { + a.Failed = a + } } for _, a0 := range a.triggers { - if a.Failed { - a0.Failed = true + if a.Failed != nil { + a0.Failed = a.Failed } if a0.pending--; a0.pending == 0 { b.ready.push(a0) @@ -1242,9 +1244,9 @@ func (b *Builder) vet(ctx context.Context, a *Action) error { // a.Deps[0] is the build of the package being vetted. // a.Deps[1] is the build of the "fmt" package. - a.Failed = false // vet of dependency may have failed but we can still succeed + a.Failed = nil // vet of dependency may have failed but we can still succeed - if a.Deps[0].Failed { + if a.Deps[0].Failed != nil { // The build of the package has failed. Skip vet check. // Vet could return export data for non-typecheck errors, // but we ignore it because the package cannot be compiled.