22 lines
370 B
Go
Raw Normal View History

2023-07-05 11:14:37 +00:00
package assert
import (
"runtime/debug"
"strings"
"testing"
)
// file returns the first line containing "_test.go" in the debug stack.
func file(t testing.TB) string {
stack := string(debug.Stack())
lines := strings.Split(stack, "\n")
for _, line := range lines {
if strings.Contains(line, "_test.go") {
return strings.TrimSpace(line)
}
}
return ""
}