MCPcopy
hub / github.com/cortesi/devd / afterTest

Function afterTest

fileserver/z_last_test.go:42–73  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

40}
41
42func afterTest(t *testing.T) {
43 http.DefaultTransport.(*http.Transport).CloseIdleConnections()
44 if testing.Short() {
45 return
46 }
47 var bad string
48 badSubstring := map[string]string{
49 ").readLoop(": "a Transport",
50 ").writeLoop(": "a Transport",
51 "created by net/http/httptest.(*Server).Start": "an httptest.Server",
52 "timeoutHandler": "a TimeoutHandler",
53 "net.(*netFD).connect(": "a timing out dial",
54 ").noteClientGone(": "a closenotifier sender",
55 }
56 var stacks string
57 for i := 0; i < 4; i++ {
58 bad = ""
59 stacks = strings.Join(interestingGoroutines(), "\n\n")
60 for substr, what := range badSubstring {
61 if strings.Contains(stacks, substr) {
62 bad = what
63 }
64 }
65 if bad == "" {
66 return
67 }
68 // Bad stuff found, but goroutines might just still be
69 // shutting down, so give it some time.
70 time.Sleep(250 * time.Millisecond)
71 }
72 t.Errorf("Test appears to have leaked %s:\n%s", bad, stacks)
73}

Callers 13

TestServeFileFunction · 0.85
TestFSRedirectFunction · 0.85
_TestFileServerCleansFunction · 0.85
TestServeFileContentTypeFunction · 0.85
TestServeFileMimeTypeFunction · 0.85
TestServeFileFromCWDFunction · 0.85
TestServeIndexHtmlFunction · 0.85
TestFileServerZeroByteFunction · 0.85
TestNotFoundOverrideFunction · 0.85

Calls 1

interestingGoroutinesFunction · 0.85

Tested by

no test coverage detected