summaryrefslogtreecommitdiff
path: root/libgo/go/net/http/main_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/net/http/main_test.go')
-rw-r--r--libgo/go/net/http/main_test.go23
1 files changed, 17 insertions, 6 deletions
diff --git a/libgo/go/net/http/main_test.go b/libgo/go/net/http/main_test.go
index 438bd2e58fd..21c850566cc 100644
--- a/libgo/go/net/http/main_test.go
+++ b/libgo/go/net/http/main_test.go
@@ -37,6 +37,8 @@ func interestingGoroutines() (gs []string) {
}
stack := strings.TrimSpace(sl[1])
if stack == "" ||
+ strings.Contains(stack, "testing.(*M).before.func1") ||
+ strings.Contains(stack, "os/signal.signal_recv") ||
strings.Contains(stack, "created by net.startServer") ||
strings.Contains(stack, "created by testing.RunTests") ||
strings.Contains(stack, "closeWriteAndWait") ||
@@ -56,8 +58,9 @@ func interestingGoroutines() (gs []string) {
// Verify the other tests didn't leave any goroutines running.
func goroutineLeaked() bool {
- if testing.Short() {
- // not counting goroutines for leakage in -short mode
+ if testing.Short() || runningBenchmarks() {
+ // Don't worry about goroutine leaks in -short mode or in
+ // benchmark mode. Too distracting when there are false positives.
return false
}
@@ -92,6 +95,18 @@ func setParallel(t *testing.T) {
}
}
+func runningBenchmarks() bool {
+ for i, arg := range os.Args {
+ if strings.HasPrefix(arg, "-test.bench=") && !strings.HasSuffix(arg, "=") {
+ return true
+ }
+ if arg == "-test.bench" && i < len(os.Args)-1 && os.Args[i+1] != "" {
+ return true
+ }
+ }
+ return false
+}
+
func afterTest(t testing.TB) {
http.DefaultTransport.(*http.Transport).CloseIdleConnections()
if testing.Short() {
@@ -151,7 +166,3 @@ func waitErrCondition(waitFor, checkEvery time.Duration, fn func() error) error
}
return err
}
-
-func closeClient(c *http.Client) {
- c.Transport.(*http.Transport).CloseIdleConnections()
-}