go: cmd/go: tests that panic or exit are marked as passing when -json flag is used
What version of Go are you using (go version)?
$ go version go version go1.14 windows/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
go env Output
$ go env set GO111MODULE=on set GOARCH=amd64 set GOBIN= set GOCACHE=C:\Users\florin\AppData\Local\go-build set GOENV=C:\Users\florin\AppData\Roaming\go\env set GOEXE=.exe set GOFLAGS= set GOHOSTARCH=amd64 set GOHOSTOS=windows set GOINSECURE= set GONOPROXY= set GONOSUMDB= set GOOS=windows set GOPATH=D:\go set GOPRIVATE= set GOPROXY=direct set GOROOT=C:\go-distros\go1.14 set GOSUMDB=sum.golang.org set GOTMPDIR= set GOTOOLDIR=C:\go-distros\go1.14\pkg\tool\windows_amd64 set GCCGO=gccgo set AR=ar set CC=gcc set CXX=g++ set CGO_ENABLED=1 set GOMOD=D:\GoLandProjects\awesomeProject26\go.mod set CGO_CFLAGS=-g -O2 set CGO_CPPFLAGS= set CGO_CXXFLAGS=-g -O2 set CGO_FFLAGS=-g -O2 set CGO_LDFLAGS=-g -O2 set PKG_CONFIG=pkg-config set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\florin\AppData\Local\Temp\go-build954171622=/tmp/go-build -gno-record-gcc-switches
What did you do?
- take the code from here: https://play.golang.org/p/sM_HbzDzmXn
- run the following commands:
go test -c -coverpkg=./... -covermode=atomic -o mytests.exe awesomeProject26
go tool test2json -t ./mytests.exe -test.v -test.coverprofile cov.out
What did you expect to see?
I would expect to see that TestName2 fails since there’s a panic there.
See the output here: https://play.golang.org/p/-9xQPOYa5iN
What did you see instead?
Test is marked as pass in the resulting json:
{
"Time":"2020-02-28T15:26:08.7281772+02:00",
"Action":"pass",
"Test":"TestName2",
"Elapsed":0.286
}
The test position doesn’t seem to matter, if it’s the first, the last, or in the middle of the test suite.
This is confirmed to happen both on Windows and Ubuntu.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 3
- Comments: 22 (14 by maintainers)
@jayconrod @bcmills the problem is still reproducible while running
test2jsondirectly. The output of Go 1.15 beta1 test run:Notice the last event, it claims that
TestColoris passed.Given the reliance of
test2jsonon-test.v, this is likely a side-effect of #24929.Thanks for the reply.
Probably yes. That’s what #35169 is about.
This issue was about a specific regression in the
-jsonoutput. Since it’s a regression, it’s been backported for 1.14.1.go testhas not produced JSON output for build failures before, so that’s being considered separately as a feature request.I think this was triggered by CL 192104.
test2jsonstarted failing open instead of failing closed.If the test binary fails for any reason (exits non-zero, fails to run),
go testis supposed to add a message to stdout. Buttest2jsondoesn’t understand the message thatgo testwrites.Will have a CL soon.