Skip to content

Commit 44a94bc

Browse files
committed
Fix output file path
1 parent b747d7c commit 44a94bc

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

assert/assertions.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"fmt"
99
"math"
1010
"os"
11-
"path/filepath"
1211
"reflect"
1312
"regexp"
1413
"runtime"
@@ -107,21 +106,21 @@ func CallerInfo() []string {
107106

108107
var pc uintptr
109108
var ok bool
110-
var file string
109+
var path string
111110
var line int
112111
var name string
113112

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

123122
// This is a huge edge case, but it will panic if this is the case, see #180
124-
if file == "<autogenerated>" {
123+
if path == "<autogenerated>" {
125124
break
126125
}
127126

@@ -140,12 +139,11 @@ func CallerInfo() []string {
140139
break
141140
}
142141

143-
parts := strings.Split(file, "/")
144-
file = parts[len(parts)-1]
142+
parts := strings.Split(path, "/")
143+
file := parts[len(parts)-1]
145144
if len(parts) > 1 {
146145
dir := parts[len(parts)-2]
147146
if (dir != "assert" && dir != "mock" && dir != "require") || file == "mock_test.go" {
148-
path, _ := filepath.Abs(file)
149147
callers = append(callers, fmt.Sprintf("%s:%d", path, line))
150148
}
151149
}

0 commit comments

Comments
 (0)