diff --git a/stack_test.go b/stack_test.go index cd7827b..da53daf 100644 --- a/stack_test.go +++ b/stack_test.go @@ -160,10 +160,7 @@ func TestTrimGOPATH(t *testing.T) { fn := runtime.FuncForPC(pc) file, _ := fn.FileLine(pc) got := trimGOPATH(fn.Name(), file) - want := tt.want - if want != got { - t.Errorf("%v: want %q, got %q", tt.Frame, want, got) - } + testFormatRegexp(t, got, "%s", tt.want) } } @@ -174,24 +171,24 @@ func TestStackTrace(t *testing.T) { }{{ New("ooh"), []string{ "github.com/pkg/errors.TestStackTrace\n" + - "\t.+/github.com/pkg/errors/stack_test.go:175", + "\t.+/github.com/pkg/errors/stack_test.go:172", }, }, { Wrap(New("ooh"), "ahh"), []string{ "github.com/pkg/errors.TestStackTrace\n" + - "\t.+/github.com/pkg/errors/stack_test.go:180", // this is the stack of Wrap, not New + "\t.+/github.com/pkg/errors/stack_test.go:177", // 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:185", // this is the stack of New + "\t.+/github.com/pkg/errors/stack_test.go:182", // this is the stack of New }, }, { func() error { return New("ooh") }(), []string{ `github.com/pkg/errors.(func·005|TestStackTrace.func1)` + - "\n\t.+/github.com/pkg/errors/stack_test.go:190", // this is the stack of New + "\n\t.+/github.com/pkg/errors/stack_test.go:187", // this is the stack of New "github.com/pkg/errors.TestStackTrace\n" + - "\t.+/github.com/pkg/errors/stack_test.go:190", // this is the stack of New's caller + "\t.+/github.com/pkg/errors/stack_test.go:187", // this is the stack of New's caller }, }, { Cause(func() error { @@ -200,11 +197,11 @@ func TestStackTrace(t *testing.T) { }() }()), []string{ `github.com/pkg/errors.(func·006|TestStackTrace.func2.1)` + - "\n\t.+/github.com/pkg/errors/stack_test.go:199", // this is the stack of Errorf + "\n\t.+/github.com/pkg/errors/stack_test.go:196", // this is the stack of Errorf `github.com/pkg/errors.(func·007|TestStackTrace.func2)` + - "\n\t.+/github.com/pkg/errors/stack_test.go:200", // this is the stack of Errorf's caller + "\n\t.+/github.com/pkg/errors/stack_test.go:197", // this is the stack of Errorf's caller "github.com/pkg/errors.TestStackTrace\n" + - "\t.+/github.com/pkg/errors/stack_test.go:201", // this is the stack of Errorf's caller's caller + "\t.+/github.com/pkg/errors/stack_test.go:198", // this is the stack of Errorf's caller's caller }, }} for _, tt := range tests { @@ -274,19 +271,19 @@ func TestStackTraceFormat(t *testing.T) { }, { stackTrace()[:2], "%v", - `\[stack_test.go:228 stack_test.go:275\]`, + `\[stack_test.go:225 stack_test.go:272\]`, }, { stackTrace()[:2], "%+v", "\n" + "github.com/pkg/errors.stackTrace\n" + - "\t.+/github.com/pkg/errors/stack_test.go:228\n" + + "\t.+/github.com/pkg/errors/stack_test.go:225\n" + "github.com/pkg/errors.TestStackTraceFormat\n" + - "\t.+/github.com/pkg/errors/stack_test.go:279", + "\t.+/github.com/pkg/errors/stack_test.go:276", }, { stackTrace()[:2], "%#v", - `\[\]errors.Frame{stack_test.go:228, stack_test.go:287}`, + `\[\]errors.Frame{stack_test.go:225, stack_test.go:284}`, }} for _, tt := range tests {