Skip to content

Commit 9060fa5

Browse files
committed
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 <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 49b3ab0 commit 9060fa5

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

src/cmd/go/internal/test/test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,9 +1387,9 @@ func (r *runTestActor) Act(b *work.Builder, ctx context.Context, a *work.Action)
13871387
// Release next test to start (test2json.NewConverter writes the start event).
13881388
close(r.next)
13891389

1390-
if a.Failed {
1390+
if a.Failed != nil {
13911391
// We were unable to build the binary.
1392-
a.Failed = false
1392+
a.Failed = nil
13931393
fmt.Fprintf(stdout, "FAIL\t%s [build failed]\n", a.Package.ImportPath)
13941394
// Tell the JSON converter that this was a failure, not a passing run.
13951395
err = errors.New("build failed")

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ type Action struct {
110110
// Execution state.
111111
pending int // number of deps yet to complete
112112
priority int // relative execution priority
113-
Failed bool // whether the action failed
113+
Failed *Action // set to root cause if the action failed
114114
json *actionJSON // action graph information
115115
nonGoOverlay map[string]string // map from non-.go source files to copied files in objdir. Nil if no overlay is used.
116116
traceSpan *trace.Span
@@ -218,7 +218,7 @@ func actionGraphJSON(a *Action) string {
218218
Args: a.Args,
219219
Objdir: a.Objdir,
220220
Target: a.Target,
221-
Failed: a.Failed,
221+
Failed: a.Failed != nil,
222222
Priority: a.priority,
223223
Built: a.built,
224224
VetxOnly: a.VetxOnly,

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func (b *Builder) Do(ctx context.Context, root *Action) {
138138
a.json.TimeStart = time.Now()
139139
}
140140
var err error
141-
if a.Actor != nil && (!a.Failed || a.IgnoreFail) {
141+
if a.Actor != nil && (a.Failed == nil || a.IgnoreFail) {
142142
// TODO(matloob): Better action descriptions
143143
desc := "Executing action (" + a.Mode
144144
if a.Package != nil {
@@ -176,12 +176,14 @@ func (b *Builder) Do(ctx context.Context, root *Action) {
176176
sh := b.Shell(a)
177177
sh.Errorf("%s", err)
178178
}
179-
a.Failed = true
179+
if a.Failed == nil {
180+
a.Failed = a
181+
}
180182
}
181183

182184
for _, a0 := range a.triggers {
183-
if a.Failed {
184-
a0.Failed = true
185+
if a.Failed != nil {
186+
a0.Failed = a.Failed
185187
}
186188
if a0.pending--; a0.pending == 0 {
187189
b.ready.push(a0)
@@ -1242,9 +1244,9 @@ func (b *Builder) vet(ctx context.Context, a *Action) error {
12421244
// a.Deps[0] is the build of the package being vetted.
12431245
// a.Deps[1] is the build of the "fmt" package.
12441246

1245-
a.Failed = false // vet of dependency may have failed but we can still succeed
1247+
a.Failed = nil // vet of dependency may have failed but we can still succeed
12461248

1247-
if a.Deps[0].Failed {
1249+
if a.Deps[0].Failed != nil {
12481250
// The build of the package has failed. Skip vet check.
12491251
// Vet could return export data for non-typecheck errors,
12501252
// but we ignore it because the package cannot be compiled.

0 commit comments

Comments
 (0)