@@ -44,6 +44,7 @@ import (
44
44
"os/exec"
45
45
"path/filepath"
46
46
"regexp"
47
+ "runtime"
47
48
"strconv"
48
49
"strings"
49
50
"sync/atomic"
@@ -70,14 +71,24 @@ func NewTestingReporter(t *testing.T) *TestingReporter {
70
71
71
72
// Errorf prints the provided message to TestingL and stops the test using testing.T.Fatalf.
72
73
func (r * TestingReporter ) Errorf (format string , v ... interface {}) {
73
- TestingL .Printf (format , v ... )
74
- r .t .Fatalf (format , v ... )
74
+ msg := fmt .Sprintf (format , v ... )
75
+ _ , file , lineNum , ok := runtime .Caller (2 )
76
+ if ok {
77
+ r .t .Fatalf ("%s:%d: %s" , file , lineNum , msg )
78
+ } else {
79
+ r .t .Fatalf (format , v ... )
80
+ }
75
81
}
76
82
77
83
// Logf prints the provided message to TestingL testing.T.
78
84
func (r * TestingReporter ) Logf (format string , v ... interface {}) {
79
- TestingL .Printf (format , v ... )
80
- r .t .Logf (format , v ... )
85
+ msg := fmt .Sprintf (format , v ... )
86
+ _ , file , lineNum , ok := runtime .Caller (2 )
87
+ if ok {
88
+ r .t .Logf ("%s:%d: %s" , file , lineNum , msg )
89
+ } else {
90
+ r .t .Logf (format , v ... )
91
+ }
81
92
}
82
93
83
94
// Stdout returns the writer to TestingL as stdout. This enables to print command logs realtime.
0 commit comments