]> Cypherpunks repositories - gostls13.git/commitdiff
log/slog: fix window race builder
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Wed, 22 Mar 2023 04:13:23 +0000 (11:13 +0700)
committerGopher Robot <gobot@golang.org>
Wed, 22 Mar 2023 11:02:00 +0000 (11:02 +0000)
Bench log file is created non-portably, only works on system where
"/tmp" existed and "/" is path separator.

Fixing this by using portable methods from std lib.

Updates #56345

Change-Id: I1f6b6b97b913ca56a6053beca7025652618ecbf3
Reviewed-on: https://go-review.googlesource.com/c/go/+/478355
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/log/slog/json_handler_test.go

index dc15df4580e5ccfb5b8f6f4026914c9a202e975f..55e05d58e3526f8515774fe400ffde43d22a406f 100644 (file)
@@ -14,6 +14,7 @@ import (
        "log/slog/internal/buffer"
        "math"
        "os"
+       "path/filepath"
        "strings"
        "testing"
        "time"
@@ -201,7 +202,7 @@ func BenchmarkPreformatting(b *testing.B) {
                }),
        }
 
-       outFile, err := os.Create("/tmp/bench.log")
+       outFile, err := os.Create(filepath.Join(b.TempDir(), "bench.log"))
        if err != nil {
                b.Fatal(err)
        }