@@ -146,49 +146,31 @@ func TestFuncname(t *testing.T) {
146146 }
147147}
148148
149- func TestTrimGOPATH (t * testing.T ) {
150- var tests = []struct {
151- Frame
152- want string
153- }{{
154- Frame (initpc ),
155- "github.com/pkg/errors/stack_test.go" ,
156- }}
157-
158- for i , tt := range tests {
159- pc := tt .Frame .pc ()
160- fn := runtime .FuncForPC (pc )
161- file , _ := fn .FileLine (pc )
162- got := trimGOPATH (fn .Name (), file )
163- testFormatRegexp (t , i , got , "%s" , tt .want )
164- }
165- }
166-
167149func TestStackTrace (t * testing.T ) {
168150 tests := []struct {
169151 err error
170152 want []string
171153 }{{
172154 New ("ooh" ), []string {
173155 "github.com/pkg/errors.TestStackTrace\n " +
174- "\t .+/github.com/pkg/errors/stack_test.go:172 " ,
156+ "\t .+/github.com/pkg/errors/stack_test.go:154 " ,
175157 },
176158 }, {
177159 Wrap (New ("ooh" ), "ahh" ), []string {
178160 "github.com/pkg/errors.TestStackTrace\n " +
179- "\t .+/github.com/pkg/errors/stack_test.go:177 " , // this is the stack of Wrap, not New
161+ "\t .+/github.com/pkg/errors/stack_test.go:159 " , // this is the stack of Wrap, not New
180162 },
181163 }, {
182164 Cause (Wrap (New ("ooh" ), "ahh" )), []string {
183165 "github.com/pkg/errors.TestStackTrace\n " +
184- "\t .+/github.com/pkg/errors/stack_test.go:182 " , // this is the stack of New
166+ "\t .+/github.com/pkg/errors/stack_test.go:164 " , // this is the stack of New
185167 },
186168 }, {
187169 func () error { return New ("ooh" ) }(), []string {
188170 `github.com/pkg/errors.(func·009|TestStackTrace.func1)` +
189- "\n \t .+/github.com/pkg/errors/stack_test.go:187 " , // this is the stack of New
171+ "\n \t .+/github.com/pkg/errors/stack_test.go:169 " , // this is the stack of New
190172 "github.com/pkg/errors.TestStackTrace\n " +
191- "\t .+/github.com/pkg/errors/stack_test.go:187 " , // this is the stack of New's caller
173+ "\t .+/github.com/pkg/errors/stack_test.go:169 " , // this is the stack of New's caller
192174 },
193175 }, {
194176 Cause (func () error {
@@ -197,11 +179,11 @@ func TestStackTrace(t *testing.T) {
197179 }()
198180 }()), []string {
199181 `github.com/pkg/errors.(func·010|TestStackTrace.func2.1)` +
200- "\n \t .+/github.com/pkg/errors/stack_test.go:196 " , // this is the stack of Errorf
182+ "\n \t .+/github.com/pkg/errors/stack_test.go:178 " , // this is the stack of Errorf
201183 `github.com/pkg/errors.(func·011|TestStackTrace.func2)` +
202- "\n \t .+/github.com/pkg/errors/stack_test.go:197 " , // this is the stack of Errorf's caller
184+ "\n \t .+/github.com/pkg/errors/stack_test.go:179 " , // this is the stack of Errorf's caller
203185 "github.com/pkg/errors.TestStackTrace\n " +
204- "\t .+/github.com/pkg/errors/stack_test.go:198 " , // this is the stack of Errorf's caller's caller
186+ "\t .+/github.com/pkg/errors/stack_test.go:180 " , // this is the stack of Errorf's caller's caller
205187 },
206188 }}
207189 for i , tt := range tests {
@@ -271,19 +253,19 @@ func TestStackTraceFormat(t *testing.T) {
271253 }, {
272254 stackTrace ()[:2 ],
273255 "%v" ,
274- `\[stack_test.go:225 stack_test.go:272 \]` ,
256+ `\[stack_test.go:207 stack_test.go:254 \]` ,
275257 }, {
276258 stackTrace ()[:2 ],
277259 "%+v" ,
278260 "\n " +
279261 "github.com/pkg/errors.stackTrace\n " +
280- "\t .+/github.com/pkg/errors/stack_test.go:225 \n " +
262+ "\t .+/github.com/pkg/errors/stack_test.go:207 \n " +
281263 "github.com/pkg/errors.TestStackTraceFormat\n " +
282- "\t .+/github.com/pkg/errors/stack_test.go:276 " ,
264+ "\t .+/github.com/pkg/errors/stack_test.go:258 " ,
283265 }, {
284266 stackTrace ()[:2 ],
285267 "%#v" ,
286- `\[\]errors.Frame{stack_test.go:225 , stack_test.go:284 }` ,
268+ `\[\]errors.Frame{stack_test.go:207 , stack_test.go:266 }` ,
287269 }}
288270
289271 for i , tt := range tests {
0 commit comments