Commit 57337da1 authored by Russ Cox's avatar Russ Cox

testing: use debug.SetTraceback("all") to show all goroutines at test timeout

Fixes #13681.

Change-Id: I308930f4d9200fbe0f09cd08c38392ca1bb0db67
Reviewed-on: https://go-review.googlesource.com/18044Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: default avatarAustin Clements <austin@google.com>
parent bb0567b3
...@@ -165,7 +165,7 @@ var pkgDeps = map[string][]string{ ...@@ -165,7 +165,7 @@ var pkgDeps = map[string][]string{
"runtime/trace": {"L0"}, "runtime/trace": {"L0"},
"text/tabwriter": {"L2"}, "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/iotest": {"L2", "log"},
"testing/quick": {"L2", "flag", "fmt", "reflect"}, "testing/quick": {"L2", "flag", "fmt", "reflect"},
"internal/testenv": {"L2", "os", "testing"}, "internal/testenv": {"L2", "os", "testing"},
......
...@@ -2,10 +2,11 @@ ...@@ -2,10 +2,11 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package debug package debug_test
import ( import (
"runtime" "runtime"
. "runtime/debug"
"testing" "testing"
"time" "time"
) )
......
...@@ -2,12 +2,13 @@ ...@@ -2,12 +2,13 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package debug package debug_test
import ( import (
"io/ioutil" "io/ioutil"
"os" "os"
"runtime" "runtime"
. "runtime/debug"
"testing" "testing"
) )
......
...@@ -2,9 +2,10 @@ ...@@ -2,9 +2,10 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package debug package debug_test
import ( import (
. "runtime/debug"
"strings" "strings"
"testing" "testing"
) )
...@@ -51,9 +52,9 @@ func TestStack(t *testing.T) { ...@@ -51,9 +52,9 @@ func TestStack(t *testing.T) {
} }
n++ n++
frame("src/runtime/debug/stack.go", "runtime/debug.Stack") 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_test.(*T).ptrmethod")
frame("src/runtime/debug/stack_test.go", "runtime/debug.T.method") frame("src/runtime/debug/stack_test.go", "runtime/debug_test.T.method")
frame("src/runtime/debug/stack_test.go", "runtime/debug.TestStack") frame("src/runtime/debug/stack_test.go", "runtime/debug_test.TestStack")
frame("src/testing/testing.go", "") frame("src/testing/testing.go", "")
} }
......
...@@ -149,6 +149,7 @@ import ( ...@@ -149,6 +149,7 @@ import (
"fmt" "fmt"
"os" "os"
"runtime" "runtime"
"runtime/debug"
"runtime/pprof" "runtime/pprof"
"runtime/trace" "runtime/trace"
"strconv" "strconv"
...@@ -714,6 +715,7 @@ var timer *time.Timer ...@@ -714,6 +715,7 @@ var timer *time.Timer
func startAlarm() { func startAlarm() {
if *timeout > 0 { if *timeout > 0 {
timer = time.AfterFunc(*timeout, func() { timer = time.AfterFunc(*timeout, func() {
debug.SetTraceback("all")
panic(fmt.Sprintf("test timed out after %v", *timeout)) panic(fmt.Sprintf("test timed out after %v", *timeout))
}) })
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment