From 9b6231a1ab9d3497816c4f9ebae6815443922dd1 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Wed, 22 Mar 2023 11:13:23 +0700 Subject: [PATCH] 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 --- src/log/slog/json_handler_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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) } -- 2.50.0