| 54 | } |
| 55 | |
| 56 | func TestStackFormat(t *testing.T) { |
| 57 | |
| 58 | defer func() { |
| 59 | err := recover() |
| 60 | if err != 'a' { |
| 61 | t.Fatal(err) |
| 62 | } |
| 63 | |
| 64 | e, expected := Errorf("hi"), callers() |
| 65 | |
| 66 | bs := [][]uintptr{e.stack, expected} |
| 67 | |
| 68 | if err := compareStacks(bs[0], bs[1]); err != nil { |
| 69 | t.Errorf("Stack didn't match") |
| 70 | t.Errorf(err.Error()) |
| 71 | } |
| 72 | |
| 73 | stack := string(e.Stack()) |
| 74 | |
| 75 | if !strings.Contains(stack, "a: b(5)") { |
| 76 | t.Errorf("Stack trace does not contain source line: 'a: b(5)'") |
| 77 | t.Errorf(stack) |
| 78 | } |
| 79 | if !strings.Contains(stack, "error_test.go:") { |
| 80 | t.Errorf("Stack trace does not contain file name: 'error_test.go:'") |
| 81 | t.Errorf(stack) |
| 82 | } |
| 83 | }() |
| 84 | |
| 85 | a() |
| 86 | } |
| 87 | |
| 88 | func TestSkipWorks(t *testing.T) { |
| 89 | |