Currently, if a test or imported package fails to build during "go test -json", the build error text will be interleaved with the JSON output of tests. Furthermore, there’s currently no way to reliably associate a build error with the test package or packages it affected. This creates unnecessary friction and complexity in tools that consume the "go test -json" output. This CL makes "go test -json" enable JSON reporting of build errors. It also adds a "FailedBuild" field to the "fail" TestEvent, which gives the package ID of the package that failed to build and caused the test to fail. Using this, CI systems should be able to consume the entire output stream from "go test -json" in a structured way and easily associate build failures with test failures during reporting. Fixes #62067. Updates #35169. Updates #37486. Change-Id: I49091dcc7aa52db01fc9fa6042771633e97b8407 Reviewed-on: https://go-review.googlesource.com/c/go/+/536399 Reviewed-by: Russ Cox <rsc@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
1.5 KiB
Tools
Go command
The go build
and go install
commands now accept a -json
flag that reports
build output and failures as structured JSON output on standard output.
Furthermore, passing -json
to go test
now reports build output and failures
in addition to test results in JSON. For details of the reporting format, see
go help buildjson
.
Cgo
Cgo currently refuses to compile calls to a C function which has multiple
incompatible declarations. For instance, if f
is declared as both void f(int)
and void f(double)
, cgo will report an error instead of possibly generating an
incorrect call sequence for f(0)
. New in this release is a better detector for
this error condition when the incompatible declarations appear in different
files. See #67699.
Vet
The new tests
analyzer reports common mistakes in declarations of
tests, fuzzers, benchmarks, and examples in test packages, such as
malformed names, incorrect signatures, or examples that document
non-existent identifiers. Some of these mistakes may cause tests not
to run.
This analyzer is among the subset of analyzers that are run by go test
.
GOCACHEPROG
The cmd/go
internal binary and test caching mechanism can now be implemented
by child processes implementing a JSON protocol between the cmd/go
tool
and the child process named by the GOCACHEPROG
environment variable.
This was previously behind a GOEXPERIMENT.
For protocol details, see #59719.