From: Cuong Manh Le Date: Wed, 22 Mar 2023 04:13:23 +0000 (+0700) Subject: log/slog: fix window race builder X-Git-Tag: go1.21rc1~1192 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=9b6231a1ab9d3497816c4f9ebae6815443922dd1;p=gostls13.git log/slog: fix window race builder 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 Reviewed-by: Ian Lance Taylor Auto-Submit: Ian Lance Taylor Reviewed-by: Jonathan Amsterdam Run-TryBot: Cuong Manh Le TryBot-Result: Gopher Robot --- diff --git a/src/log/slog/json_handler_test.go b/src/log/slog/json_handler_test.go index dc15df4580..55e05d58e3 100644 --- a/src/log/slog/json_handler_test.go +++ b/src/log/slog/json_handler_test.go @@ -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) }