|
|
@@ -146,24 +146,6 @@ func TestFuncname(t *testing.T) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func TestTrimGOPATH(t *testing.T) {
|
|
|
- var tests = []struct {
|
|
|
- Frame
|
|
|
- want string
|
|
|
- }{{
|
|
|
- Frame(initpc),
|
|
|
- "github.com/pkg/errors/stack_test.go",
|
|
|
- }}
|
|
|
-
|
|
|
- for i, tt := range tests {
|
|
|
- pc := tt.Frame.pc()
|
|
|
- fn := runtime.FuncForPC(pc)
|
|
|
- file, _ := fn.FileLine(pc)
|
|
|
- got := trimGOPATH(fn.Name(), file)
|
|
|
- testFormatRegexp(t, i, got, "%s", tt.want)
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
func TestStackTrace(t *testing.T) {
|
|
|
tests := []struct {
|
|
|
err error
|
|
|
@@ -171,24 +153,24 @@ func TestStackTrace(t *testing.T) {
|
|
|
}{{
|
|
|
New("ooh"), []string{
|
|
|
"github.com/pkg/errors.TestStackTrace\n" +
|
|
|
- "\t.+/github.com/pkg/errors/stack_test.go:172",
|
|
|
+ "\t.+/github.com/pkg/errors/stack_test.go:154",
|
|
|
},
|
|
|
}, {
|
|
|
Wrap(New("ooh"), "ahh"), []string{
|
|
|
"github.com/pkg/errors.TestStackTrace\n" +
|
|
|
- "\t.+/github.com/pkg/errors/stack_test.go:177", // this is the stack of Wrap, not New
|
|
|
+ "\t.+/github.com/pkg/errors/stack_test.go:159", // this is the stack of Wrap, not New
|
|
|
},
|
|
|
}, {
|
|
|
Cause(Wrap(New("ooh"), "ahh")), []string{
|
|
|
"github.com/pkg/errors.TestStackTrace\n" +
|
|
|
- "\t.+/github.com/pkg/errors/stack_test.go:182", // this is the stack of New
|
|
|
+ "\t.+/github.com/pkg/errors/stack_test.go:164", // this is the stack of New
|
|
|
},
|
|
|
}, {
|
|
|
func() error { return New("ooh") }(), []string{
|
|
|
`github.com/pkg/errors.(func·009|TestStackTrace.func1)` +
|
|
|
- "\n\t.+/github.com/pkg/errors/stack_test.go:187", // this is the stack of New
|
|
|
+ "\n\t.+/github.com/pkg/errors/stack_test.go:169", // this is the stack of New
|
|
|
"github.com/pkg/errors.TestStackTrace\n" +
|
|
|
- "\t.+/github.com/pkg/errors/stack_test.go:187", // this is the stack of New's caller
|
|
|
+ "\t.+/github.com/pkg/errors/stack_test.go:169", // this is the stack of New's caller
|
|
|
},
|
|
|
}, {
|
|
|
Cause(func() error {
|
|
|
@@ -197,11 +179,11 @@ func TestStackTrace(t *testing.T) {
|
|
|
}()
|
|
|
}()), []string{
|
|
|
`github.com/pkg/errors.(func·010|TestStackTrace.func2.1)` +
|
|
|
- "\n\t.+/github.com/pkg/errors/stack_test.go:196", // this is the stack of Errorf
|
|
|
+ "\n\t.+/github.com/pkg/errors/stack_test.go:178", // this is the stack of Errorf
|
|
|
`github.com/pkg/errors.(func·011|TestStackTrace.func2)` +
|
|
|
- "\n\t.+/github.com/pkg/errors/stack_test.go:197", // this is the stack of Errorf's caller
|
|
|
+ "\n\t.+/github.com/pkg/errors/stack_test.go:179", // this is the stack of Errorf's caller
|
|
|
"github.com/pkg/errors.TestStackTrace\n" +
|
|
|
- "\t.+/github.com/pkg/errors/stack_test.go:198", // this is the stack of Errorf's caller's caller
|
|
|
+ "\t.+/github.com/pkg/errors/stack_test.go:180", // this is the stack of Errorf's caller's caller
|
|
|
},
|
|
|
}}
|
|
|
for i, tt := range tests {
|
|
|
@@ -271,19 +253,19 @@ func TestStackTraceFormat(t *testing.T) {
|
|
|
}, {
|
|
|
stackTrace()[:2],
|
|
|
"%v",
|
|
|
- `\[stack_test.go:225 stack_test.go:272\]`,
|
|
|
+ `\[stack_test.go:207 stack_test.go:254\]`,
|
|
|
}, {
|
|
|
stackTrace()[:2],
|
|
|
"%+v",
|
|
|
"\n" +
|
|
|
"github.com/pkg/errors.stackTrace\n" +
|
|
|
- "\t.+/github.com/pkg/errors/stack_test.go:225\n" +
|
|
|
+ "\t.+/github.com/pkg/errors/stack_test.go:207\n" +
|
|
|
"github.com/pkg/errors.TestStackTraceFormat\n" +
|
|
|
- "\t.+/github.com/pkg/errors/stack_test.go:276",
|
|
|
+ "\t.+/github.com/pkg/errors/stack_test.go:258",
|
|
|
}, {
|
|
|
stackTrace()[:2],
|
|
|
"%#v",
|
|
|
- `\[\]errors.Frame{stack_test.go:225, stack_test.go:284}`,
|
|
|
+ `\[\]errors.Frame{stack_test.go:207, stack_test.go:266}`,
|
|
|
}}
|
|
|
|
|
|
for i, tt := range tests {
|