Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: go test -json has non-JSON printed to stdout when build fails #35169

Open
ailurarctos opened this issue Oct 26, 2019 · 2 comments

Comments

@ailurarctos
Copy link

@ailurarctos ailurarctos commented Oct 26, 2019

What version of Go are you using (go version)?

$ go version
go version go1.13.3 linux/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
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/me/.cache/go-build"
GOENV="/home/me/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/me/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/me/example.com/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build779567786=/tmp/go-build -gno-record-gcc-switches"
GOROOT/bin/go version: go version go1.13.3 linux/amd64
GOROOT/bin/go tool compile -V: compile version go1.13.3
uname -sr: Linux 5.3.7-arch1-1-ARCH
/usr/lib/libc.so.6: GNU C Library (GNU libc) stable release version 2.30.

What did you do?

Run go test -json when a package has a build failure. Here is my example_test.go:

package example

import "testing"

func Test(t *testing.T) {
	broken
}

What did you expect to see?

I expected to see JSON events similar to when a package is skipped because it has no tests. Here is an example:

{"Time":"2019-10-26T09:09:27.272054198+09:00","Action":"output","Package":"example.com","Output":"FAIL\texample.com [build failed]\n"}
{"Time":"2019-10-26T09:09:27.272173706+09:00","Action":"fail","Package":"example.com","Elapsed":0}

What did you see instead?

The package result is printed as-is to stdout:

example.com]$ go test -json 2>/dev/null
FAIL	example.com [build failed]
@ailurarctos

This comment has been minimized.

Copy link
Author

@ailurarctos ailurarctos commented Oct 26, 2019

This issue might be related to (or a duplicate of) #23037 but I'm not sure because that ticket seems to ask for -json support in go build. What I'm hoping for is to not have go test -json print non-JSON to stdout.

@dmitshur dmitshur changed the title go test -json: non-JSON printed to stdout when build fails cmd/go: go test -json has non-JSON printed to stdout when build fails Oct 29, 2019
@dmitshur

This comment has been minimized.

Copy link
Member

@dmitshur dmitshur commented Oct 29, 2019

@dmitshur dmitshur added the GoCommand label Oct 29, 2019
@jayconrod jayconrod added this to the Unplanned milestone Oct 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.