Skip to content

Commit

Permalink
Fix CallerInfo() source file paths (#1288)
Browse files Browse the repository at this point in the history
  • Loading branch information
bozaro committed Jan 3, 2023
1 parent 2b00d33 commit 0ab3ce1
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions assert/assertions.go
Expand Up @@ -8,7 +8,6 @@ import (
"fmt"
"math"
"os"
"path/filepath"
"reflect"
"regexp"
"runtime"
Expand Down Expand Up @@ -141,12 +140,11 @@ func CallerInfo() []string {
}

parts := strings.Split(file, "/")
file = parts[len(parts)-1]
if len(parts) > 1 {
filename := parts[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))
if (dir != "assert" && dir != "mock" && dir != "require") || filename == "mock_test.go" {
callers = append(callers, fmt.Sprintf("%s:%d", file, line))
}
}

Expand Down

0 comments on commit 0ab3ce1

Please sign in to comment.