Skip to content

Commit e6a7e0e

Browse files
committed
main_test.go: Add to detect goroutine leaks
Updates #330
1 parent 108d137 commit e6a7e0e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

main_test.go

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package websocket_test
2+
3+
import (
4+
"fmt"
5+
"os"
6+
"runtime"
7+
"testing"
8+
)
9+
10+
func TestMain(m *testing.M) {
11+
code := m.Run()
12+
if runtime.NumGoroutine() != 1 {
13+
fmt.Fprintf(os.Stderr, "goroutine leak detected, expected 1 but got %d goroutines\n", runtime.NumGoroutine())
14+
os.Exit(1)
15+
}
16+
os.Exit(code)
17+
}

0 commit comments

Comments
 (0)