Skip to content

Commit

Permalink
windows requires no slashes in path names
Browse files Browse the repository at this point in the history
  • Loading branch information
torcolvin committed Aug 15, 2024
1 parent be7687f commit 5c00b7d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion base/logging_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"fmt"
"os"
"path/filepath"
"regexp"
"runtime"
"testing"
"time"
Expand Down Expand Up @@ -325,7 +326,10 @@ func lumberjackTempDir(t *testing.T) string {
}
// On Windows, cleanup of t.TempDir() fails due to open log file handle from Lumberjack. Cannot be fixed from SG.
// https://github.com/natefinch/lumberjack/issues/185
logPath, err := os.MkdirTemp("", t.Name())

// windows requires no slashes in the path name
pathRegex := regexp.MustCompile(`/|\\`)
logPath, err := os.MkdirTemp("", string(pathRegex.ReplaceAll([]byte(t.Name()), []byte("_"))))
require.NoError(t, err)
t.Cleanup(func() {
if err := os.RemoveAll(logPath); err != nil {
Expand Down

0 comments on commit 5c00b7d

Please sign in to comment.