Skip to content

Commit a9952c0

Browse files
committed
remove duplicate logging on integ tests, add info for where log came from
Signed-off-by: Scott Haddlesey <[email protected]>
1 parent 711afec commit a9952c0

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

util/testutil/shell.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import (
4444
"os/exec"
4545
"path/filepath"
4646
"regexp"
47+
"runtime"
4748
"strconv"
4849
"strings"
4950
"sync/atomic"
@@ -70,14 +71,24 @@ func NewTestingReporter(t *testing.T) *TestingReporter {
7071

7172
// Errorf prints the provided message to TestingL and stops the test using testing.T.Fatalf.
7273
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+
}
7581
}
7682

7783
// Logf prints the provided message to TestingL testing.T.
7884
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+
}
8192
}
8293

8394
// Stdout returns the writer to TestingL as stdout. This enables to print command logs realtime.

0 commit comments

Comments
 (0)