Skip to content

Commit

Permalink
Fix output file path
Browse files Browse the repository at this point in the history
  • Loading branch information
bozaro committed Oct 26, 2022
1 parent b747d7c commit 44a94bc
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions assert/assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"fmt"
"math"
"os"
"path/filepath"
"reflect"
"regexp"
"runtime"
Expand Down Expand Up @@ -107,21 +106,21 @@ func CallerInfo() []string {

var pc uintptr
var ok bool
var file string
var path string
var line int
var name string

callers := []string{}
for i := 0; ; i++ {
pc, file, line, ok = runtime.Caller(i)
pc, path, line, ok = runtime.Caller(i)
if !ok {
// The breaks below failed to terminate the loop, and we ran off the
// end of the call stack.
break
}

// This is a huge edge case, but it will panic if this is the case, see #180
if file == "<autogenerated>" {
if path == "<autogenerated>" {
break
}

Expand All @@ -140,12 +139,11 @@ func CallerInfo() []string {
break
}

parts := strings.Split(file, "/")
file = parts[len(parts)-1]
parts := strings.Split(path, "/")
file := parts[len(parts)-1]
if len(parts) > 1 {
dir := parts[len(parts)-2]
if (dir != "assert" && dir != "mock" && dir != "require") || file == "mock_test.go" {
path, _ := filepath.Abs(file)
callers = append(callers, fmt.Sprintf("%s:%d", path, line))
}
}
Expand Down

0 comments on commit 44a94bc

Please sign in to comment.