]> Cypherpunks repositories - gostls13.git/commitdiff
testing: use debug.SetTraceback("all") to show all goroutines at test timeout
authorRuss Cox <rsc@golang.org>
Fri, 18 Dec 2015 16:24:55 +0000 (11:24 -0500)
committerRuss Cox <rsc@golang.org>
Fri, 18 Dec 2015 20:51:32 +0000 (20:51 +0000)
Fixes #13681.

Change-Id: I308930f4d9200fbe0f09cd08c38392ca1bb0db67
Reviewed-on: https://go-review.googlesource.com/18044
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
src/go/build/deps_test.go
src/runtime/debug/garbage_test.go
src/runtime/debug/heapdump_test.go
src/runtime/debug/stack_test.go
src/testing/testing.go

index b16893861eb3e324126c988d4c6bd2cbbe88ba52..4603102526ffa3ded9f52c23e5fe5e42b8674f73 100644 (file)
@@ -165,7 +165,7 @@ var pkgDeps = map[string][]string{
        "runtime/trace":  {"L0"},
        "text/tabwriter": {"L2"},
 
-       "testing":          {"L2", "flag", "fmt", "os", "runtime/pprof", "runtime/trace", "time"},
+       "testing":          {"L2", "flag", "fmt", "os", "runtime/debug", "runtime/pprof", "runtime/trace", "time"},
        "testing/iotest":   {"L2", "log"},
        "testing/quick":    {"L2", "flag", "fmt", "reflect"},
        "internal/testenv": {"L2", "os", "testing"},
index 549d360bbf7bfb1639049a83b46cc8f623ceeb9e..d834da84fc76f06ae52ecc4bc4399b0b2a662b85 100644 (file)
@@ -2,10 +2,11 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package debug
+package debug_test
 
 import (
        "runtime"
+       . "runtime/debug"
        "testing"
        "time"
 )
index cb2f2f06798a4882144912696f9a246aac79ce48..5761c015b8e28676565aabdd805b3eb722ba432f 100644 (file)
@@ -2,12 +2,13 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package debug
+package debug_test
 
 import (
        "io/ioutil"
        "os"
        "runtime"
+       . "runtime/debug"
        "testing"
 )
 
index d2a4ea5b374f6c1cc00d9b2751fe005f6b8aaa73..f54437231b05b715bf3102743ccac818d0a4f783 100644 (file)
@@ -2,9 +2,10 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package debug
+package debug_test
 
 import (
+       . "runtime/debug"
        "strings"
        "testing"
 )
@@ -51,9 +52,9 @@ func TestStack(t *testing.T) {
        }
        n++
        frame("src/runtime/debug/stack.go", "runtime/debug.Stack")
-       frame("src/runtime/debug/stack_test.go", "runtime/debug.(*T).ptrmethod")
-       frame("src/runtime/debug/stack_test.go", "runtime/debug.T.method")
-       frame("src/runtime/debug/stack_test.go", "runtime/debug.TestStack")
+       frame("src/runtime/debug/stack_test.go", "runtime/debug_test.(*T).ptrmethod")
+       frame("src/runtime/debug/stack_test.go", "runtime/debug_test.T.method")
+       frame("src/runtime/debug/stack_test.go", "runtime/debug_test.TestStack")
        frame("src/testing/testing.go", "")
 }
 
index 99d77984319f84820b27ddbca68e04fdfe9c48ed..2081365abf3f14b4255a73aa2f07bf5c5e79422a 100644 (file)
@@ -149,6 +149,7 @@ import (
        "fmt"
        "os"
        "runtime"
+       "runtime/debug"
        "runtime/pprof"
        "runtime/trace"
        "strconv"
@@ -714,6 +715,7 @@ var timer *time.Timer
 func startAlarm() {
        if *timeout > 0 {
                timer = time.AfterFunc(*timeout, func() {
+                       debug.SetTraceback("all")
                        panic(fmt.Sprintf("test timed out after %v", *timeout))
                })
        }