1 package errors
2
3 import (
4 "reflect"
5 "testing"
6 )
7
8 var createdBy = `panic: hello!
9
10 goroutine 54 [running]:
11 runtime.panic(0x35ce40, 0xc208039db0)
12 /0/c/go/src/pkg/runtime/panic.c:279 +0xf5
13 github.com/loopj/bugsnag-example-apps/go/revelapp/app/controllers.func·001()
14 /0/go/src/github.com/loopj/bugsnag-example-apps/go/revelapp/app/controllers/app.go:13 +0x74
15 net/http.(*Server).Serve(0xc20806c780, 0x910c88, 0xc20803e168, 0x0, 0x0)
16 /0/c/go/src/pkg/net/http/server.go:1698 +0x91
17 created by github.com/loopj/bugsnag-example-apps/go/revelapp/app/controllers.App.Index
18 /0/go/src/github.com/loopj/bugsnag-example-apps/go/revelapp/app/controllers/app.go:14 +0x3e
19
20 goroutine 16 [IO wait]:
21 net.runtime_pollWait(0x911c30, 0x72, 0x0)
22 /0/c/go/src/pkg/runtime/netpoll.goc:146 +0x66
23 net.(*pollDesc).Wait(0xc2080ba990, 0x72, 0x0, 0x0)
24 /0/c/go/src/pkg/net/fd_poll_runtime.go:84 +0x46
25 net.(*pollDesc).WaitRead(0xc2080ba990, 0x0, 0x0)
26 /0/c/go/src/pkg/net/fd_poll_runtime.go:89 +0x42
27 net.(*netFD).accept(0xc2080ba930, 0x58be30, 0x0, 0x9103f0, 0x23)
28 /0/c/go/src/pkg/net/fd_unix.go:409 +0x343
29 net.(*TCPListener).AcceptTCP(0xc20803e168, 0x8, 0x0, 0x0)
30 /0/c/go/src/pkg/net/tcpsock_posix.go:234 +0x5d
31 net.(*TCPListener).Accept(0xc20803e168, 0x0, 0x0, 0x0, 0x0)
32 /0/c/go/src/pkg/net/tcpsock_posix.go:244 +0x4b
33 github.com/revel/revel.Run(0xe6d9)
34 /0/go/src/github.com/revel/revel/server.go:113 +0x926
35 main.main()
36 /0/go/src/github.com/loopj/bugsnag-example-apps/go/revelapp/app/tmp/main.go:109 +0xe1a
37 `
38
39 var normalSplit = `panic: hello!
40
41 goroutine 54 [running]:
42 runtime.panic(0x35ce40, 0xc208039db0)
43 /0/c/go/src/pkg/runtime/panic.c:279 +0xf5
44 github.com/loopj/bugsnag-example-apps/go/revelapp/app/controllers.func·001()
45 /0/go/src/github.com/loopj/bugsnag-example-apps/go/revelapp/app/controllers/app.go:13 +0x74
46 net/http.(*Server).Serve(0xc20806c780, 0x910c88, 0xc20803e168, 0x0, 0x0)
47 /0/c/go/src/pkg/net/http/server.go:1698 +0x91
48
49 goroutine 16 [IO wait]:
50 net.runtime_pollWait(0x911c30, 0x72, 0x0)
51 /0/c/go/src/pkg/runtime/netpoll.goc:146 +0x66
52 net.(*pollDesc).Wait(0xc2080ba990, 0x72, 0x0, 0x0)
53 /0/c/go/src/pkg/net/fd_poll_runtime.go:84 +0x46
54 net.(*pollDesc).WaitRead(0xc2080ba990, 0x0, 0x0)
55 /0/c/go/src/pkg/net/fd_poll_runtime.go:89 +0x42
56 net.(*netFD).accept(0xc2080ba930, 0x58be30, 0x0, 0x9103f0, 0x23)
57 /0/c/go/src/pkg/net/fd_unix.go:409 +0x343
58 net.(*TCPListener).AcceptTCP(0xc20803e168, 0x8, 0x0, 0x0)
59 /0/c/go/src/pkg/net/tcpsock_posix.go:234 +0x5d
60 net.(*TCPListener).Accept(0xc20803e168, 0x0, 0x0, 0x0, 0x0)
61 /0/c/go/src/pkg/net/tcpsock_posix.go:244 +0x4b
62 github.com/revel/revel.Run(0xe6d9)
63 /0/go/src/github.com/revel/revel/server.go:113 +0x926
64 main.main()
65 /0/go/src/github.com/loopj/bugsnag-example-apps/go/revelapp/app/tmp/main.go:109 +0xe1a
66 `
67
68 var lastGoroutine = `panic: hello!
69
70 goroutine 16 [IO wait]:
71 net.runtime_pollWait(0x911c30, 0x72, 0x0)
72 /0/c/go/src/pkg/runtime/netpoll.goc:146 +0x66
73 net.(*pollDesc).Wait(0xc2080ba990, 0x72, 0x0, 0x0)
74 /0/c/go/src/pkg/net/fd_poll_runtime.go:84 +0x46
75 net.(*pollDesc).WaitRead(0xc2080ba990, 0x0, 0x0)
76 /0/c/go/src/pkg/net/fd_poll_runtime.go:89 +0x42
77 net.(*netFD).accept(0xc2080ba930, 0x58be30, 0x0, 0x9103f0, 0x23)
78 /0/c/go/src/pkg/net/fd_unix.go:409 +0x343
79 net.(*TCPListener).AcceptTCP(0xc20803e168, 0x8, 0x0, 0x0)
80 /0/c/go/src/pkg/net/tcpsock_posix.go:234 +0x5d
81 net.(*TCPListener).Accept(0xc20803e168, 0x0, 0x0, 0x0, 0x0)
82 /0/c/go/src/pkg/net/tcpsock_posix.go:244 +0x4b
83 github.com/revel/revel.Run(0xe6d9)
84 /0/go/src/github.com/revel/revel/server.go:113 +0x926
85 main.main()
86 /0/go/src/github.com/loopj/bugsnag-example-apps/go/revelapp/app/tmp/main.go:109 +0xe1a
87
88 goroutine 54 [running]:
89 runtime.panic(0x35ce40, 0xc208039db0)
90 /0/c/go/src/pkg/runtime/panic.c:279 +0xf5
91 github.com/loopj/bugsnag-example-apps/go/revelapp/app/controllers.func·001()
92 /0/go/src/github.com/loopj/bugsnag-example-apps/go/revelapp/app/controllers/app.go:13 +0x74
93 net/http.(*Server).Serve(0xc20806c780, 0x910c88, 0xc20803e168, 0x0, 0x0)
94 /0/c/go/src/pkg/net/http/server.go:1698 +0x91
95 `
96
97 var result = []StackFrame{
98 StackFrame{File: "/0/c/go/src/pkg/runtime/panic.c", LineNumber: 279, Name: "panic", Package: "runtime"},
99 StackFrame{File: "/0/go/src/github.com/loopj/bugsnag-example-apps/go/revelapp/app/controllers/app.go", LineNumber: 13, Name: "func.001", Package: "github.com/loopj/bugsnag-example-apps/go/revelapp/app/controllers"},
100 StackFrame{File: "/0/c/go/src/pkg/net/http/server.go", LineNumber: 1698, Name: "(*Server).Serve", Package: "net/http"},
101 }
102
103 var resultCreatedBy = append(result,
104 StackFrame{File: "/0/go/src/github.com/loopj/bugsnag-example-apps/go/revelapp/app/controllers/app.go", LineNumber: 14, Name: "App.Index", Package: "github.com/loopj/bugsnag-example-apps/go/revelapp/app/controllers", ProgramCounter: 0x0})
105
106 func TestParsePanic(t *testing.T) {
107
108 todo := map[string]string{
109 "createdBy": createdBy,
110 "normalSplit": normalSplit,
111 "lastGoroutine": lastGoroutine,
112 }
113
114 for key, val := range todo {
115 Err, err := ParsePanic(val)
116
117 if err != nil {
118 t.Fatal(err)
119 }
120
121 if Err.TypeName() != "panic" {
122 t.Errorf("Wrong type: %s", Err.TypeName())
123 }
124
125 if Err.Error() != "hello!" {
126 t.Errorf("Wrong message: %s", Err.TypeName())
127 }
128
129 if Err.StackFrames()[0].Func() != nil {
130 t.Errorf("Somehow managed to find a func...")
131 }
132
133 result := result
134 if key == "createdBy" {
135 result = resultCreatedBy
136 }
137
138 if !reflect.DeepEqual(Err.StackFrames(), result) {
139 t.Errorf("Wrong stack for %s: %#v", key, Err.StackFrames())
140 }
141 }
142 }
143
View as plain text