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: avoid leaking goroutines #124

Merged
merged 1 commit into from
Apr 2, 2024
Merged

Commits on Apr 2, 2024

  1. test: avoid leaking goroutines

    This commit adds a test that checks for goroutine
    leaks in the `workerpool` package, and also fixes
    two goroutine leaks.
    
    There is unfortunately no easy way of running
    `goleak` before every test without either a lot of
    copy-paste, or additional code to ensure every
    test file has a `TestMain` function.
    
    A leaked goroutine will produce the following
    error with `goleak`:
    
    ```
    goleak: Errors on successful test run: found
    unexpected goroutines: [Goroutine 7 in state chan
    receive, with
    github.com/nlnwa/warchaeology/internal/workerpool
    .New.func1 on top of the stack: goroutine 7 [chan
    receive]:
    github.com/nlnwa/warchaeology/internal/workerpool.
    New.func1(0xc00008a1e0)
    ./warchaeology/internal/workerpool/workerpool.go:
    23
    +0x66 created by
    github.com/nlnwa/warchaeology/internal/workerpool.New
    in goroutine 6
    ./warchaeology/internal/workerpool/workerpool.go:
    22
    +0x85 ] FAIL
    github.com/nlnwa/warchaeology/internal/workerpool
    0.450s FAIL
    ```
    trym-b committed Apr 2, 2024
    Configuration menu
    Copy the full SHA
    67ab417 View commit details
    Browse the repository at this point in the history