1
0
mirror of https://github.com/beego/bee.git synced 2024-11-23 11:50:55 +00:00
bee/vendor/github.com/smartystreets/goconvey/convey/gotest/utils.go

29 lines
831 B
Go
Raw Normal View History

2016-12-05 15:07:45 +00:00
// Package gotest contains internal functionality. Although this package
// contains one or more exported names it is not intended for public
// consumption. See the examples package for how to use this project.
package gotest
import (
"runtime"
"strings"
)
func ResolveExternalCaller() (file string, line int, name string) {
var caller_id uintptr
callers := runtime.Callers(0, callStack)
for x := 0; x < callers; x++ {
caller_id, file, line, _ = runtime.Caller(x)
if strings.HasSuffix(file, "_test.go") || strings.HasSuffix(file, "_tests.go") {
name = runtime.FuncForPC(caller_id).Name()
return
}
}
file, line, name = "<unkown file>", -1, "<unknown name>"
return // panic?
}
const maxStackDepth = 100 // This had better be enough...
var callStack []uintptr = make([]uintptr, maxStackDepth, maxStackDepth)