Skip to content

Commit

Permalink
main_test.go: Add to detect goroutine leaks
Browse files Browse the repository at this point in the history
Updates #330
  • Loading branch information
nhooyr committed Oct 19, 2023
1 parent 108d137 commit e6a7e0e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions main_test.go
@@ -0,0 +1,17 @@
package websocket_test

import (
"fmt"
"os"
"runtime"
"testing"
)

func TestMain(m *testing.M) {
code := m.Run()
if runtime.NumGoroutine() != 1 {
fmt.Fprintf(os.Stderr, "goroutine leak detected, expected 1 but got %d goroutines\n", runtime.NumGoroutine())
os.Exit(1)
}
os.Exit(code)
}

0 comments on commit e6a7e0e

Please sign in to comment.