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

testing: output failure report to stderr as per docu instead of stdout #16138

Closed
tpepper opened this issue Jun 21, 2016 · 4 comments

Comments

Projects
None yet
3 participants
@tpepper
Copy link

commented Jun 21, 2016

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?
    1.6.2
    (installed via go1.6.2.linux-amd64.tar.gz at https://golang.org/dl/)
  2. What operating system and processor architecture are you using (go env)?
    The OS is Fedora 23 (Workstation Edition). The go env output doesn't quite capture that fully:

GOARCH="amd64"
GOBIN="/usr/src/go/bin"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/usr/src/go"
GORACE=""
GOROOT="/usr/src/golang-1.6"
GOTOOLDIR="/usr/src/golang-1.6/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"

  1. What did you do?
    go code https://play.golang.org/p/6GR6cTzVcM
    go test case for that code https://play.golang.org/p/ZEJ2iNJMPV

Run a simple test case that fails, outputting a t.Fatal(err).

  1. What did you expect to see?

https://golang.org/pkg/testing/#T indicates that testing logs are accumulated and output to stderr so I expect the t.Fatal() output report to be on stderr.

  1. What did you see instead?

The report output is on stdout.

It seems like something as trivial as tpepper@c60fccd (which is on top of tip's changes to allow subtests) could bring the report output in line with the documentation. But as noted in that tentative commit message, this might break users who have coded to the behavior without reporting the inconsistency. Perhaps the answer is to change the documentation, except the enabling the distinction between stdout and stderr is actually useful.

@tpepper tpepper changed the title testing: testing: output to stderr as per docu instead of stdout Jun 21, 2016

@tpepper tpepper changed the title testing: output to stderr as per docu instead of stdout testing: output failure report to stderr as per docu instead of stdout Jun 21, 2016

@tpepper

This comment has been minimized.

Copy link
Author

commented Jun 21, 2016

./all.bash fails with my above referenced "fix", highlighting existing test cases are indeed coded to expect other than the documented behavior:

--- FAIL: TestVendorTest (0.13s)
    go_test.go:244: running testgo [test -v]
    go_test.go:259: standard output:
    go_test.go:260: PASS
        ok      vend/hello  0.001s

    go_test.go:263: standard error:
    go_test.go:264: === RUN   TestMsgInternal
        --- PASS: TestMsgInternal (0.00s)
        === RUN   TestMsgExternal
        --- PASS: TestMsgExternal (0.00s)

    go_test.go:349: missing use in internal test
    go_test.go:350: pattern TestMsgInternal not found in standard output
FAIL
FAIL    cmd/go  22.235s
@tpepper

This comment has been minimized.

Copy link
Author

commented Jun 21, 2016

tpepper@bf45959 trivially fixes the test case to match the fixed testing package. Then ./all.bash passes. But everything else in the golang universe might have failures.

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Jun 21, 2016

It's been this way for a long time, so I think we should change the documentation.

@ianlancetaylor ianlancetaylor added this to the Go1.7Maybe milestone Jun 21, 2016

@gopherbot

This comment has been minimized.

Copy link

commented Jun 21, 2016

CL https://golang.org/cl/24311 mentions this issue.

@gopherbot gopherbot closed this in aa6345d Jun 23, 2016

@golang golang locked and limited conversation to collaborators Jun 23, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.