Skip to content

Commit fd4b8cf

Browse files
committed
assert.CallerInfo: cleanup
Move the stackFrameBufferSize const which was in package scope but used only by CallerInfo, into CallerInfo body.
1 parent 5c94955 commit fd4b8cf

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

assert/assertions.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ import (
2424
"github.com/stretchr/testify/assert/yaml"
2525
)
2626

27-
const stackFrameBufferSize = 10
28-
2927
//go:generate sh -c "cd ../_codegen && go build && cd - && ../_codegen/_codegen -output-package=assert -template=assertion_format.go.tmpl"
3028

3129
// TestingT is an interface wrapper around *testing.T
@@ -217,8 +215,10 @@ func CallerInfo() []string {
217215
var line int
218216
var name string
219217

220-
callers := []string{}
218+
const stackFrameBufferSize = 10
221219
pcs := make([]uintptr, stackFrameBufferSize)
220+
221+
callers := []string{}
222222
offset := 1
223223

224224
for {
@@ -273,13 +273,14 @@ func CallerInfo() []string {
273273
isTest(name, "Example") {
274274
break
275275
}
276+
276277
if !more {
277278
break
278279
}
279280
}
280-
// We know we already have less than a buffer's worth of frames
281-
offset += stackFrameBufferSize
282281

282+
// Next batch
283+
offset += cap(pcs)
283284
}
284285

285286
return callers

0 commit comments

Comments
 (0)