json.Exited(err)
json.Close()
}()
- json.SetFailedBuild(perr.Desc())
+ 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())
+ }
stdout = json
}
fmt.Fprintf(stdout, "FAIL\t%s [setup failed]\n", p.ImportPath)
if a.Failed != nil {
// We were unable to build the binary.
if json != nil && a.Failed.Package != nil {
- json.SetFailedBuild(a.Failed.Package.Desc())
+ if gotestjsonbuildtext.Value() == "1" {
+ gotestjsonbuildtext.IncNonDefault()
+ } else {
+ json.SetFailedBuild(a.Failed.Package.Desc())
+ }
}
a.Failed = nil
fmt.Fprintf(stdout, "FAIL\t%s [build failed]\n", a.Package.ImportPath)
stderr 'builderror'${/}'main_test.go:3:11: undefined: y\n'
stdout '"Action":"start","Package":"m/builderror"'
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 --
module m