github.com/gopherjs/gopherjs@v1.19.0-beta1.0.20240506212314-27071a8796e4/compiler/natives/src/net/http/main_test.go (about) 1 //go:build js && wasm 2 // +build js,wasm 3 4 package http_test 5 6 import ( 7 "runtime" 8 "sort" 9 "strings" 10 ) 11 12 // This is an almost verbatim copy of the upstream, except one line which was 13 // adjusted to match GopherJS call stacks. 14 // This overlay can be remoed if/when https://github.com/golang/go/pull/49128 15 // is merged and reached a stable Go release (likely 1.18). 16 func interestingGoroutines() (gs []string) { 17 buf := make([]byte, 2<<20) 18 buf = buf[:runtime.Stack(buf, true)] 19 for _, g := range strings.Split(string(buf), "\n\n") { 20 sl := strings.SplitN(g, "\n", 2) 21 if len(sl) != 2 { 22 continue 23 } 24 stack := strings.TrimSpace(sl[1]) 25 if stack == "" || 26 strings.Contains(stack, "testing.(*M).before.func1") || 27 strings.Contains(stack, "os/signal.signal_recv") || 28 strings.Contains(stack, "created by net.startServer") || 29 strings.Contains(stack, "created by testing.RunTests") || 30 strings.Contains(stack, "closeWriteAndWait") || 31 strings.Contains(stack, "testing.Main(") || 32 // These only show up with GOTRACEBACK=2; Issue 5005 (comment 28) 33 strings.Contains(stack, "runtime.goexit") || 34 strings.Contains(stack, "created by runtime.gc") || 35 strings.Contains(stack, "interestingGoroutines") || // ← Changed line. 36 strings.Contains(stack, "runtime.MHeap_Scavenger") { 37 continue 38 } 39 gs = append(gs, stack) 40 } 41 sort.Strings(gs) 42 return 43 }