veyron/lib/testutil/integration: improve Start logging
This CL will cause the caller of Start to be logged. This makes it easy
to tell which line of code in your test started a particular binary. If
the binary fails, this output is helpful for debugging purposes.
Change-Id: Ief0790c74d940a3c63ce7a20d68957cae3ca94f4
diff --git a/lib/testutil/integration/util.go b/lib/testutil/integration/util.go
index 4b7c47f..8547e8f 100644
--- a/lib/testutil/integration/util.go
+++ b/lib/testutil/integration/util.go
@@ -10,6 +10,7 @@
"os/exec"
"path"
"path/filepath"
+ "runtime"
"strings"
"syscall"
"testing"
@@ -199,7 +200,11 @@
}
func (b *integrationTestBinary) Start(args ...string) Invocation {
- b.env.t.Logf("starting %s %s", b.Path(), strings.Join(args, " "))
+ locationString := ""
+ if _, file, line, ok := runtime.Caller(1); ok {
+ locationString = fmt.Sprintf("(requested at %s:%d) ", filepath.Base(file), line)
+ }
+ b.env.t.Logf("%sstarting %s %s", locationString, b.Path(), strings.Join(args, " "))
handle, err := b.env.shell.Start("exec", nil, append([]string{b.Path()}, args...)...)
if err != nil {
b.env.t.Fatalf("Start(%v, %v) failed: %v", b.Path(), strings.Join(args, ", "), err)