sweet: ensure go tool stderr is always preserved
This is the first step toward providing error output from subprocesses.
Change-Id: I8ffe0705397b4e9605979d0852a4eb031bb35651
Reviewed-on: https://go-review.googlesource.com/c/benchmarks/+/383534
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
diff --git a/sweet/common/gotool.go b/sweet/common/gotool.go
index e892556..6113d1f 100644
--- a/sweet/common/gotool.go
+++ b/sweet/common/gotool.go
@@ -38,7 +38,12 @@
cmd.Stderr = os.Stderr
}
log.TraceCommand(cmd, false)
- return cmd.Run()
+ if g.PassOutput {
+ return cmd.Run()
+ }
+ // Use cmd.Output to get an ExitError with Stderr populated.
+ _, err := cmd.Output()
+ return err
}
func (g *Go) List(args ...string) ([]byte, error) {