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: spurious linefeed + backspace (\r\u0008) characters in go test -json output on Windows #51207

Closed
shueybubbles opened this issue Feb 15, 2022 · 5 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Windows
Milestone

Comments

@shueybubbles
Copy link

On Windows 10 I see unexpected output in one of our tests. I do not see this extra output on Linux.
Perhaps there's some obscure bug in our code but we don't have anything that obviously emits such a strange combination as \r\u0008.

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

go version go1.17.1 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=
set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=D:\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=D:\go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.17.1
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=E:\git\go-sqlcmd\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

What did you do?

git clone https://github.com/microsoft/go-sqlcmd
set SQLCMDSERVER=mysqlservername
go test -json ./...

What did you expect to see?

{"Time":"2022-02-15T15:16:17.355648516Z","Action":"output","Package":"github.com/microsoft/go-sqlcmd/cmd/sqlcmd","Test":"TestQueryAndExit","Output":"--- PASS: TestQueryAndExit (0.71s)\n"}

What did you see instead?

{"Time":"2022-02-15T10:03:01.7125903-05:00","Action":"output","Package":"github.com/microsoft/go-sqlcmd/cmd/sqlcmd","Test":"TestQueryAndExit","Output":"\r\u0008\r\u0008\r\u0008--- PASS: TestQueryAndExit (0.62s)\n"}
@dmitshur dmitshur changed the title Spurious linefeed + backspace (\r\u0008) characters in go test output on Windows cmd/go: spurious linefeed + backspace (\r\u0008) characters in go test -json output on Windows Feb 15, 2022
@dmitshur
Copy link
Contributor

CC @bcmills, @matloob.

@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 15, 2022
@dmitshur dmitshur added this to the Backlog milestone Feb 15, 2022
@bcmills
Copy link
Member

bcmills commented Feb 15, 2022

\u0008 is BACKSPACE. I

However, at first glance this looks like a variation on #26325 / #33419. Probably something else in the test is writing to the test's stdout or stderr, and because the extra output doesn't occur at a newline boundary, cmd/test2json isn't able to parse past it.

@bcmills
Copy link
Member

bcmills commented Feb 15, 2022

Duplicate of #26325

@bcmills bcmills marked this as a duplicate of #26325 Feb 15, 2022
@bcmills bcmills closed this as completed Feb 15, 2022
@shueybubbles
Copy link
Author

shueybubbles commented Feb 15, 2022

@bcmills afaict this particular test doesn't use stdout at all. I don't see anything in #26325 discussion that suggests how I could work around it. And why is it OS-specific? FWIW it's not just in the json, the backspace characters are encoded in plain text when not using -json.

@bcmills
Copy link
Member

bcmills commented Feb 15, 2022

FWIW it's not just in the json, the backspace characters are encoded in plain text when not using -json.

That's exactly what I'm saying. The testing package (and go test) does not inject those characters in the text itself, so they must be coming from some other package linked into the test binary.

You could try compiling the test and setting a debugger breakpoint to figure out what is writing those bytes. Perhaps they're coming from a subprocess (via os/exec) that has been set to forward its own stdout and/or stderr?

@golang golang locked and limited conversation to collaborators Feb 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Windows
Projects
None yet
Development

No branches or pull requests

4 participants