Skip to content

Test timeouts #5

@lukechampine

Description

@lukechampine

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions