Skip to content

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

Closed

Description

@tpepper

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.

Activity

  1. changed the title [-]testing: [/-] [+]testing: output to stderr as per docu instead of stdout[/+] on Jun 21, 2016
  2. 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[/+] on Jun 21, 2016
  3. tpepper commented on Jun 21, 2016

    @tpepper
    Author

    ./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
    
  4. tpepper commented on Jun 21, 2016

    @tpepper
    Author

    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.

  5. ianlancetaylor commented on Jun 21, 2016

    @ianlancetaylor
    Contributor

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

  6. added this to the Go1.7Maybe milestone on Jun 21, 2016
  7. gopherbot commented on Jun 21, 2016

    @gopherbot
    Contributor

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

  8. locked and limited conversation to collaborators on Jun 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions