sweet: emit log filename in addition to log tail on error

This change makes Sweet emit the filename of the log most likely to
contain useful information in addition to the tail of that log on
failure.

Change-Id: I28e890f6108d56544efe6fba44225d7c42dc31e8
Reviewed-on: https://go-review.googlesource.com/c/benchmarks/+/615575
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
diff --git a/sweet/cmd/sweet/benchmark.go b/sweet/cmd/sweet/benchmark.go
index 2b2fa7c..30006a7 100644
--- a/sweet/cmd/sweet/benchmark.go
+++ b/sweet/cmd/sweet/benchmark.go
@@ -363,7 +363,6 @@
 		if err != nil {
 			return fmt.Errorf("create %s log file for %s: %v", b.name, cfg.Name, err)
 		}
-		defer results.Close()
 		setups = append(setups, common.RunConfig{
 			BinDir:    binDir,
 			TmpDir:    tmpDir,
@@ -400,8 +399,9 @@
 				if tailErr != nil {
 					logTail = fmt.Sprintf("error reading log tail: %s", tailErr)
 				}
+				logName := setup.Log.Name()
 				setup.Log.Close()
-				return fmt.Errorf("run benchmark %s for config %s: %v\nLog tail:\n%s", b.name, cfgs[i].Name, err, logTail)
+				return fmt.Errorf("run benchmark %s for config %s: %v\nTail of log (%s):\n%s", b.name, cfgs[i].Name, err, logName, logTail)
 			}
 			debug.SetGCPercent(gogc)