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: confusing failures when t.Error called after test has returned #15654

Closed
neild opened this issue May 11, 2016 · 3 comments
Closed

testing: confusing failures when t.Error called after test has returned #15654

neild opened this issue May 11, 2016 · 3 comments

Comments

@neild
Copy link
Contributor

neild commented May 11, 2016

Pre-1.7, calling t.Error after a Test function returned had no effect. Now it causes the test suite to fail, but (confusingly) the cause of the failure isn't reported in any way.

package t_test

import (
        "testing"
        "time"
)

func TestA(t *testing.T) {
        go func() {
                time.Sleep(10 * time.Millisecond)
                t.Errorf("failed after success")
        }()
}

func TestB(t *testing.T) {
        time.Sleep(1 * time.Second)
}
$ go version
go version go1.6 linux/amd64
$ go test . -test.v
=== RUN   TestA
--- PASS: TestA (0.00s)
=== RUN   TestB
--- PASS: TestB (1.00s)
PASS
ok      _/usr/local/google/home/dneil/src/testex        1.022s
$ ~/go/bin/go version
go version devel +15285d4 Wed Apr 27 11:08:58 2016 -0700 linux/amd64
$ ~/go/bin/go test . -test.v
=== RUN   TestA
--- PASS: TestA (0.00s)
=== RUN   TestB
--- PASS: TestB (1.00s)
FAIL
exit status 1
FAIL    _/usr/local/google/home/dneil/src/testex        1.013s

The test is clearly at fault, so this becoming a failure isn't a problem at all. However, it's not at all obvious why the test has failed; every test passes and then the test run fails inexplicably.

@josharian
Copy link
Contributor

@mpvl

@bradfitz bradfitz added this to the Go1.7 milestone May 12, 2016
@bradfitz bradfitz self-assigned this May 12, 2016
@gopherbot
Copy link

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

@bradfitz bradfitz assigned mpvl and unassigned bradfitz May 20, 2016
@gopherbot
Copy link

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

@rsc rsc modified the milestones: Go1.7Beta, Go1.7 May 24, 2016
@golang golang locked and limited conversation to collaborators May 24, 2017
@rsc rsc unassigned mpvl Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants