Skip to content

Commit 0ab3ce1

Browse files
authored
Fix CallerInfo() source file paths (#1288)
1 parent 2b00d33 commit 0ab3ce1

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

assert/assertions.go

+3-5
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"
@@ -141,12 +140,11 @@ func CallerInfo() []string {
141140
}
142141

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

0 commit comments

Comments
 (0)