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: test2json does not recognize test status if output did not end with new line #47032

Closed
suzmue opened this issue Jul 2, 2021 · 2 comments
Labels
FrozenDueToAge GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@suzmue
Copy link
Contributor

suzmue commented Jul 2, 2021

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

$ go version
go version go1.16.5 darwin/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="/Users/suzmue/Library/Caches/go-build"
GOENV="/Users/suzmue/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/suzmue/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/suzmue/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.16.5"
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 -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/2x/hlwbwjzd1vd4brlfs80676fw00fkl_/T/go-build1010910032=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

go test -json -run ^TestSetVariable$ github.com/go-delve/delve/service/dap

What did you expect to see?

I expected to see an event with "pass" action for the test that passed.

{"Time":"...","Action":"run","Package":"github.com/go-delve/delve/service/dap","Test":"TestSetVariableWithCall"}
{"Time":"...","Action":"output","Package":"github.com/go-delve/delve/service/dap","Test":"TestSetVariableWithCall","Output":"=== RUN   TestSetVariableWithCall\n"}
...
{"Time":"...","Action":"output","Package":"github.com/go-delve/delve/service/dap","Test":"TestSetVariableWithCall","Output":"about to break--- PASS: TestSetVariableWithCall (17.32s)\n"}
{"Time":"...,"Action":"pass","Package":"github.com/go-delve/delve/service/dap","Test":"TestSetVariable","Elapsed":1.24} // This was missing
{"Time":"...","Action":"output","Package":"github.com/go-delve/delve/service/dap","Output":"PASS\n"}
{"Time":"...","Action":"output","Package":"github.com/go-delve/delve/service/dap","Output":"ok  \tgithub.com/go-delve/delve/service/dap\t18.301s\n"}
{"Time":"...","Action":"pass","Package":"github.com/go-delve/delve/service/dap","Elapsed":18.303}

What did you see instead?

No event for the test.

{"Time":"...","Action":"run","Package":"github.com/go-delve/delve/service/dap","Test":"TestSetVariableWithCall"}
{"Time":"...","Action":"output","Package":"github.com/go-delve/delve/service/dap","Test":"TestSetVariableWithCall","Output":"=== RUN   TestSetVariableWithCall\n"}
...
{"Time":"...","Action":"output","Package":"github.com/go-delve/delve/service/dap","Test":"TestSetVariableWithCall","Output":"about to break--- PASS: TestSetVariableWithCall (17.32s)\n"}
{"Time":"...","Action":"output","Package":"github.com/go-delve/delve/service/dap","Output":"PASS\n"}
{"Time":"...","Action":"output","Package":"github.com/go-delve/delve/service/dap","Output":"ok  \tgithub.com/go-delve/delve/service/dap\t18.301s\n"}
{"Time":"...","Action":"pass","Package":"github.com/go-delve/delve/service/dap","Elapsed":18.303}

test2json checks for lines beginning with: (spaces)--- PASS:, but in this test the last output from the test did not contain a new line, so the status message was appended to the same line, and it did not get parsed as a passing test.

@dmitshur dmitshur added GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Jul 2, 2021
@dmitshur dmitshur added this to the Backlog milestone Jul 2, 2021
@dmitshur
Copy link
Contributor

dmitshur commented Jul 2, 2021

CC @jayconrod, @bcmills.

@jayconrod
Copy link
Contributor

Closing as a duplicate of #26325.

Unfortunately, we still don't have a solution for that. The testing package writes structured line-based output to stdout, and tests can write stuff there too that interferes.

@golang golang locked and limited conversation to collaborators Jul 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants