Skip to content
This repository was archived by the owner on Dec 1, 2021. It is now read-only.

Commit 2a9be18

Browse files
expdavecheney
authored andcommitted
Modify TestTrimGOPATH to ensure tests pass while vendored (#78)
1 parent 1d2e603 commit 2a9be18

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

stack_test.go

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,7 @@ func TestTrimGOPATH(t *testing.T) {
160160
fn := runtime.FuncForPC(pc)
161161
file, _ := fn.FileLine(pc)
162162
got := trimGOPATH(fn.Name(), file)
163-
want := tt.want
164-
if want != got {
165-
t.Errorf("%v: want %q, got %q", tt.Frame, want, got)
166-
}
163+
testFormatRegexp(t, got, "%s", tt.want)
167164
}
168165
}
169166

@@ -174,24 +171,24 @@ func TestStackTrace(t *testing.T) {
174171
}{{
175172
New("ooh"), []string{
176173
"github.com/pkg/errors.TestStackTrace\n" +
177-
"\t.+/github.com/pkg/errors/stack_test.go:175",
174+
"\t.+/github.com/pkg/errors/stack_test.go:172",
178175
},
179176
}, {
180177
Wrap(New("ooh"), "ahh"), []string{
181178
"github.com/pkg/errors.TestStackTrace\n" +
182-
"\t.+/github.com/pkg/errors/stack_test.go:180", // this is the stack of Wrap, not New
179+
"\t.+/github.com/pkg/errors/stack_test.go:177", // this is the stack of Wrap, not New
183180
},
184181
}, {
185182
Cause(Wrap(New("ooh"), "ahh")), []string{
186183
"github.com/pkg/errors.TestStackTrace\n" +
187-
"\t.+/github.com/pkg/errors/stack_test.go:185", // this is the stack of New
184+
"\t.+/github.com/pkg/errors/stack_test.go:182", // this is the stack of New
188185
},
189186
}, {
190187
func() error { return New("ooh") }(), []string{
191188
`github.com/pkg/errors.(func·005|TestStackTrace.func1)` +
192-
"\n\t.+/github.com/pkg/errors/stack_test.go:190", // this is the stack of New
189+
"\n\t.+/github.com/pkg/errors/stack_test.go:187", // this is the stack of New
193190
"github.com/pkg/errors.TestStackTrace\n" +
194-
"\t.+/github.com/pkg/errors/stack_test.go:190", // this is the stack of New's caller
191+
"\t.+/github.com/pkg/errors/stack_test.go:187", // this is the stack of New's caller
195192
},
196193
}, {
197194
Cause(func() error {
@@ -200,11 +197,11 @@ func TestStackTrace(t *testing.T) {
200197
}()
201198
}()), []string{
202199
`github.com/pkg/errors.(func·006|TestStackTrace.func2.1)` +
203-
"\n\t.+/github.com/pkg/errors/stack_test.go:199", // this is the stack of Errorf
200+
"\n\t.+/github.com/pkg/errors/stack_test.go:196", // this is the stack of Errorf
204201
`github.com/pkg/errors.(func·007|TestStackTrace.func2)` +
205-
"\n\t.+/github.com/pkg/errors/stack_test.go:200", // this is the stack of Errorf's caller
202+
"\n\t.+/github.com/pkg/errors/stack_test.go:197", // this is the stack of Errorf's caller
206203
"github.com/pkg/errors.TestStackTrace\n" +
207-
"\t.+/github.com/pkg/errors/stack_test.go:201", // this is the stack of Errorf's caller's caller
204+
"\t.+/github.com/pkg/errors/stack_test.go:198", // this is the stack of Errorf's caller's caller
208205
},
209206
}}
210207
for _, tt := range tests {
@@ -274,19 +271,19 @@ func TestStackTraceFormat(t *testing.T) {
274271
}, {
275272
stackTrace()[:2],
276273
"%v",
277-
`\[stack_test.go:228 stack_test.go:275\]`,
274+
`\[stack_test.go:225 stack_test.go:272\]`,
278275
}, {
279276
stackTrace()[:2],
280277
"%+v",
281278
"\n" +
282279
"github.com/pkg/errors.stackTrace\n" +
283-
"\t.+/github.com/pkg/errors/stack_test.go:228\n" +
280+
"\t.+/github.com/pkg/errors/stack_test.go:225\n" +
284281
"github.com/pkg/errors.TestStackTraceFormat\n" +
285-
"\t.+/github.com/pkg/errors/stack_test.go:279",
282+
"\t.+/github.com/pkg/errors/stack_test.go:276",
286283
}, {
287284
stackTrace()[:2],
288285
"%#v",
289-
`\[\]errors.Frame{stack_test.go:228, stack_test.go:287}`,
286+
`\[\]errors.Frame{stack_test.go:225, stack_test.go:284}`,
290287
}}
291288

292289
for _, tt := range tests {

0 commit comments

Comments
 (0)