Commit c0a842e5 authored by Russ Cox's avatar Russ Cox

runtime/debug: fix test when source cannot be found

This happens with GOROOT_FINAL=/somewhere/else

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5727069
parent 0eb4df0b
...@@ -39,13 +39,20 @@ func TestStack(t *testing.T) { ...@@ -39,13 +39,20 @@ func TestStack(t *testing.T) {
if len(lines) <= 6 { if len(lines) <= 6 {
t.Fatal("too few lines") t.Fatal("too few lines")
} }
check(t, lines[0], "src/pkg/runtime/debug/stack_test.go") n := 0
check(t, lines[1], "\t(*T).ptrmethod: return Stack()") frame := func(line, code string) {
check(t, lines[2], "src/pkg/runtime/debug/stack_test.go") check(t, lines[n], line)
check(t, lines[3], "\tT.method: return t.ptrmethod()") n++
check(t, lines[4], "src/pkg/runtime/debug/stack_test.go") // The source might not be available while running the test.
check(t, lines[5], "\tTestStack: b := T(0).method()") if strings.HasPrefix(lines[n], "\t") {
check(t, lines[6], "src/pkg/testing/testing.go") check(t, lines[n], code)
n++
}
}
frame("src/pkg/runtime/debug/stack_test.go", "\t(*T).ptrmethod: return Stack()")
frame("src/pkg/runtime/debug/stack_test.go", "\tT.method: return t.ptrmethod()")
frame("src/pkg/runtime/debug/stack_test.go", "\tTestStack: b := T(0).method()")
frame("src/pkg/testing/testing.go", "")
} }
func check(t *testing.T, line, has string) { func check(t *testing.T, line, has string) {
......
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