mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/go: drop FailedBuild field if gotestjsonbuildtext=1
go test -json has two new effects in Go 1.24: it implies go build -json, and it adds a FailedBuild field in test events. For compatibility, CL 629335 added gotestjsonbuildtext=1, which disables the implicit go build -json, but that CL didn't affect the FailedBuild field. In principle this shouldn't matter because it's just another JSON field, but just so we don't have to worry about some intermediate behavior, this CL makes gotestjsonbuildtext=1 disable the FailedBuild field as well. Updates #62067 Updates #70402 Change-Id: I006d1ea0468980ee2564495324e8b4ed082898af Reviewed-on: https://go-review.googlesource.com/c/go/+/635899 Auto-Submit: Austin Clements <austin@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
This commit is contained in:
parent
08770a5b94
commit
e39e965e0e
2 changed files with 15 additions and 4 deletions
|
|
@ -1009,7 +1009,13 @@ func runTest(ctx context.Context, cmd *base.Command, args []string) {
|
||||||
json.Exited(err)
|
json.Exited(err)
|
||||||
json.Close()
|
json.Close()
|
||||||
}()
|
}()
|
||||||
|
if gotestjsonbuildtext.Value() == "1" {
|
||||||
|
// While this flag is about go build -json, the other effect
|
||||||
|
// of that change was to include "FailedBuild" in the test JSON.
|
||||||
|
gotestjsonbuildtext.IncNonDefault()
|
||||||
|
} else {
|
||||||
json.SetFailedBuild(perr.Desc())
|
json.SetFailedBuild(perr.Desc())
|
||||||
|
}
|
||||||
stdout = json
|
stdout = json
|
||||||
}
|
}
|
||||||
fmt.Fprintf(stdout, "FAIL\t%s [setup failed]\n", p.ImportPath)
|
fmt.Fprintf(stdout, "FAIL\t%s [setup failed]\n", p.ImportPath)
|
||||||
|
|
@ -1437,8 +1443,12 @@ func (r *runTestActor) Act(b *work.Builder, ctx context.Context, a *work.Action)
|
||||||
if a.Failed != nil {
|
if a.Failed != nil {
|
||||||
// We were unable to build the binary.
|
// We were unable to build the binary.
|
||||||
if json != nil && a.Failed.Package != nil {
|
if json != nil && a.Failed.Package != nil {
|
||||||
|
if gotestjsonbuildtext.Value() == "1" {
|
||||||
|
gotestjsonbuildtext.IncNonDefault()
|
||||||
|
} else {
|
||||||
json.SetFailedBuild(a.Failed.Package.Desc())
|
json.SetFailedBuild(a.Failed.Package.Desc())
|
||||||
}
|
}
|
||||||
|
}
|
||||||
a.Failed = nil
|
a.Failed = nil
|
||||||
fmt.Fprintf(stdout, "FAIL\t%s [build failed]\n", a.Package.ImportPath)
|
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.
|
// Tell the JSON converter that this was a failure, not a passing run.
|
||||||
|
|
|
||||||
|
|
@ -58,8 +58,9 @@ stderr '# m/builderror \[m/builderror.test\]\n'
|
||||||
stderr 'builderror'${/}'main_test.go:3:11: undefined: y\n'
|
stderr 'builderror'${/}'main_test.go:3:11: undefined: y\n'
|
||||||
stdout '"Action":"start","Package":"m/builderror"'
|
stdout '"Action":"start","Package":"m/builderror"'
|
||||||
stdout '"Action":"output","Package":"m/builderror","Output":"FAIL\\tm/builderror \[build failed\]\\n"'
|
stdout '"Action":"output","Package":"m/builderror","Output":"FAIL\\tm/builderror \[build failed\]\\n"'
|
||||||
stdout '"Action":"fail","Package":"m/builderror","Elapsed":.*,"FailedBuild":"m/builderror \[m/builderror\.test\]"'
|
stdout '"Action":"fail","Package":"m/builderror","Elapsed":[0-9.]+\}'
|
||||||
|
# FailedBuild should NOT appear in the output in this mode.
|
||||||
|
! stdout '"FailedBuild"'
|
||||||
|
|
||||||
-- go.mod --
|
-- go.mod --
|
||||||
module m
|
module m
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue