sweet/cmd/sweet: fix benchmark error report
CL 600235 added code to print the benchmark log tail on failure, but
that code overwrote the error from the benchmark itself, causing the
log print to print a useless (generally <nil>) error. Fix this.
Change-Id: I4cd6bfeb08108b66fc5450c9e64bb13ed9fc1628
Reviewed-on: https://go-review.googlesource.com/c/benchmarks/+/600795
Auto-Submit: Austin Clements <austin@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
diff --git a/sweet/cmd/sweet/benchmark.go b/sweet/cmd/sweet/benchmark.go
index f70cae9..23cd8f1 100644
--- a/sweet/cmd/sweet/benchmark.go
+++ b/sweet/cmd/sweet/benchmark.go
@@ -380,9 +380,9 @@
if err := b.harness.Run(cfgs[i], &setup); err != nil {
debug.SetGCPercent(gogc)
// Useful error messages are often in the log. Grab the end.
- logTail, err := readFileTail(setup.Results)
- if err != nil {
- logTail = fmt.Sprintf("error reading log tail: %s", err)
+ logTail, tailErr := readFileTail(setup.Results)
+ if tailErr != nil {
+ logTail = fmt.Sprintf("error reading log tail: %s", tailErr)
}
setup.Results.Close()
return fmt.Errorf("run benchmark %s for config %s: %v\nLog tail:\n%s", b.name, cfgs[i].Name, err, logTail)