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

Test timeouts #5

Closed
lukechampine opened this issue Apr 28, 2016 · 1 comment
Closed

Test timeouts #5

lukechampine opened this issue Apr 28, 2016 · 1 comment

Comments

@lukechampine
Copy link

leaktest does not play well with go test -timeout=5s. Regardless, waiting 5 seconds for goroutines to shut down seems excessive. My expectation was that goroutines would be checked as soon as the deferred function was called.
I suggest adding an optional timeout argument to Check, or providing some other way of delaying the check. Note that if Check did not delay by default, you could implement this behavior yourself:

func TestFoo(t testing.T) {
    checkFn := leaktest.Check(t)
    defer func() {
        time.Sleep(5 * time.Second)
        checkFn()
    }()
}

Furthermore, this would give you more fine-grained control over when the check executes. For example, you could wait on a channel before checking. The only reason I propose adding an optional timeout argument is because it seems like a common case.

@fortytw2
Copy link
Owner

Ah, great suggestion 👍

I think I'll move the canonical imports to use gopkg.in shortly, mark the current version of the package as .v1 and then make a .v2 that removes the default timeout and adds a CheckTimeout(*testing.T, time.Duration) that works like you'd suggest. Sound OK?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants