sweet: run commands without Stderr set with Output
This way any *exec.ExitError that gets returned will have a populated
Stderr field.
Change-Id: I9aabe5f81bc1ff80b2bf4e304817087e36205b34
Reviewed-on: https://go-review.googlesource.com/c/benchmarks/+/384514
Reviewed-by: Michael Pratt <mpratt@google.com>
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
diff --git a/sweet/harnesses/common.go b/sweet/harnesses/common.go
index 38c7e11..92b4dd8 100644
--- a/sweet/harnesses/common.go
+++ b/sweet/harnesses/common.go
@@ -16,18 +16,20 @@
func gitShallowClone(dir, url, ref string) error {
cmd := exec.Command("git", "clone", "--depth", "1", "-b", ref, url, dir)
log.TraceCommand(cmd, false)
- return cmd.Run()
+ _, err := cmd.Output()
+ return err
}
func gitCloneToCommit(dir, url, branch, hash string) error {
cloneCmd := exec.Command("git", "clone", "-b", branch, url, dir)
log.TraceCommand(cloneCmd, false)
- if err := cloneCmd.Run(); err != nil {
+ if _, err := cloneCmd.Output(); err != nil {
return err
}
checkoutCmd := exec.Command("git", "-C", dir, "checkout", hash)
log.TraceCommand(checkoutCmd, false)
- return checkoutCmd.Run()
+ _, err := checkoutCmd.Output()
+ return err
}
func copyFile(dst, src string) error {
diff --git a/sweet/harnesses/go-build.go b/sweet/harnesses/go-build.go
index 2e57a80..aefd5a3 100644
--- a/sweet/harnesses/go-build.go
+++ b/sweet/harnesses/go-build.go
@@ -91,7 +91,8 @@
cmd := exec.Command(cfg.GoTool().Tool, "build")
cmd.Dir = filepath.Join(bcfg.BinDir, bench.name, bench.pkg)
log.TraceCommand(cmd, false)
- if err := cmd.Run(); err != nil {
+ // Call Output here to get an *ExitError with a populated Stderr field.
+ if _, err := cmd.Output(); err != nil {
return err
}
}
diff --git a/sweet/harnesses/tile38.go b/sweet/harnesses/tile38.go
index 07847ff..ab92198 100644
--- a/sweet/harnesses/tile38.go
+++ b/sweet/harnesses/tile38.go
@@ -43,7 +43,8 @@
cmd := exec.Command("make", "-C", bcfg.SrcDir)
cmd.Env = env.Collapse()
log.TraceCommand(cmd, false)
- if err := cmd.Run(); err != nil {
+ // Call Output here to get an *ExitError with a populated Stderr field.
+ if _, err := cmd.Output(); err != nil {
return err
}
// Note that no matter what we do, the build script insists on putting the