Skip to content

Commit

Permalink
include windows for cleanup retries in runtime tests (#2042)
Browse files Browse the repository at this point in the history
  • Loading branch information
zackattack01 authored Jan 10, 2025
1 parent 9f071da commit 92c6d65
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pkg/osquery/runtime/runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -827,14 +827,16 @@ func setUpTestSlogger() (*threadsafebuffer.ThreadSafeBuffer, *slog.Logger) {
// The default t.TempDir is too long of a path, creating too long of an osquery
// extension socket, on posix systems.
func testRootDirectory(t *testing.T) string {
var rootDir string

if runtime.GOOS == "windows" {
return t.TempDir()
rootDir = t.TempDir()
} else {
ulid := ulid.New()
rootDir = filepath.Join(os.TempDir(), ulid[len(ulid)-4:])
require.NoError(t, os.Mkdir(rootDir, 0700))
}

ulid := ulid.New()
rootDir := filepath.Join(os.TempDir(), ulid[len(ulid)-4:])
require.NoError(t, os.Mkdir(rootDir, 0700))

t.Cleanup(func() {
// Do a couple retries in case the directory is still in use --
// Windows is a little slow on this sometimes
Expand Down

0 comments on commit 92c6d65

Please sign in to comment.