We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
go test --json
Note: Possibly related to #33419.
go version
$ go version go version go1.13.6 darwin/amd64
I'm using the latest release.
go env
$ go env GO111MODULE="on" GOARCH="amd64" GOBIN="" GOCACHE="/Users/user/Library/Caches/go-build" GOENV="/Users/user/Library/Application Support/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GONOPROXY="git.rrdc.de" GONOSUMDB="git.rrdc.de" GOOS="darwin" GOPATH="/Users/user/go" GOPRIVATE="git.rrdc.de" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64" GCCGO="gccgo" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="/dev/null" 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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/40/qhkn9k653kd0rjgtp0mljpb40000gn/T/go-build357004700=/tmp/go-build -gno-record-gcc-switches -fno-common"
Running a test that outputs something to stdout without a newline at the end will mess up go test --json.
For example:
package main import ( "fmt" "testing" ) func TestX(t *testing.T) { fmt.Print("foo") }
go test --json should output:
{"Time":"2020-01-15T18:44:23.197981+01:00","Action":"run","Package":"git.raceresult.com/la/TestMain","Test":"TestX"} {"Time":"2020-01-15T18:44:23.199111+01:00","Action":"output","Package":"git.raceresult.com/la/TestMain","Test":"TestX","Output":"=== RUN TestX\n"} {"Time":"2020-01-15T18:44:23.199129+01:00","Action":"output","Package":"git.raceresult.com/la/TestMain","Test":"TestX","Output":"foo"} {"Time":"2020-01-15T18:44:23.199158+01:00","Action":"output","Package":"git.raceresult.com/la/TestMain","Test":"TestX","Output":"--- PASS: TestX (0.00s)\n"} {"Time":"2020-01-15T18:44:23.199163+01:00","Action":"pass","Package":"git.raceresult.com/la/TestMain","Test":"TestX","Elapsed":0} {"Time":"2020-01-15T18:44:23.199229+01:00","Action":"output","Package":"git.raceresult.com/la/TestMain","Output":"PASS\n"} {"Time":"2020-01-15T18:44:23.199261+01:00","Action":"output","Package":"git.raceresult.com/la/TestMain","Output":"ok \tgit.raceresult.com/la/TestMain\t0.321s\n"} {"Time":"2020-01-15T18:44:23.200981+01:00","Action":"pass","Package":"git.raceresult.com/la/TestMain","Elapsed":0.323}
go test --json outputs:
{"Time":"2020-01-15T18:36:09.586716+01:00","Action":"run","Package":"git.raceresult.com/la/TestMain","Test":"TestX"} {"Time":"2020-01-15T18:36:09.586898+01:00","Action":"output","Package":"git.raceresult.com/la/TestMain","Test":"TestX","Output":"=== RUN TestX\n"} {"Time":"2020-01-15T18:36:09.586909+01:00","Action":"output","Package":"git.raceresult.com/la/TestMain","Test":"TestX","Output":"foo--- PASS: TestX (0.00s)\n"} {"Time":"2020-01-15T18:36:09.586914+01:00","Action":"output","Package":"git.raceresult.com/la/TestMain","Output":"PASS\n"} {"Time":"2020-01-15T18:36:09.586918+01:00","Action":"output","Package":"git.raceresult.com/la/TestMain","Output":"ok \tgit.raceresult.com/la/TestMain\t(cached)\n"} {"Time":"2020-01-15T18:36:09.586923+01:00","Action":"pass","Package":"git.raceresult.com/la/TestMain","Elapsed":0}
The text was updated successfully, but these errors were encountered:
This is the same problem as #33419. Closing as a dup.
Sorry, something went wrong.
No branches or pull requests
Note: Possibly related to #33419.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
I'm using the latest release.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Running a test that outputs something to stdout without a newline at the end will mess up
go test --json
.For example:
What did you expect to see?
go test --json
should output:What did you see instead?
go test --json
outputs:The text was updated successfully, but these errors were encountered: