]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: track root failing Action
authorAustin Clements <austin@google.com>
Tue, 17 Oct 2023 21:21:47 +0000 (17:21 -0400)
committerAustin Clements <austin@google.com>
Sun, 17 Nov 2024 14:32:03 +0000 (14:32 +0000)
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 <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/cmd/go/internal/test/test.go
src/cmd/go/internal/work/action.go
src/cmd/go/internal/work/exec.go

index 2a83890a33c64d5b21d6ff4543acec0bf4d38880..93e0137481dc2fab441e2644691208da53996764 100644 (file)
@@ -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")
index 7567284d70d43b51b3120d14e93420006e9b31cf..ab577a6e0e1d6b0ad7f9490df0da4f2f2a194113 100644 (file)
@@ -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,
index 1aaf50f1fbbe8cea768eef525a9fcb9f69d3fca1..6fed8d9cbc3a4db9f792bc4886e36d61465be783 100644 (file)
@@ -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.