From 81539eee8f514ea2082e355e75aab75c6d9bb04e Mon Sep 17 00:00:00 2001 From: Julio Lopez <1953782+julio-lopez@users.noreply.github.com> Date: Wed, 4 Jun 2025 20:07:05 -0700 Subject: [PATCH] chore(ci): include date-time in temp dir name used for tests (#4651) While sorting by modification time is possible with OS tools, such as `ls`, including the directory creation time in the name facilitates cleanup in local dev environments where tests fail often. --- internal/testutil/tmpdir.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/testutil/tmpdir.go b/internal/testutil/tmpdir.go index 2010dae82..ca7fb5d7b 100644 --- a/internal/testutil/tmpdir.go +++ b/internal/testutil/tmpdir.go @@ -7,6 +7,7 @@ "path/filepath" "strings" "testing" + "time" "github.com/pkg/errors" "github.com/stretchr/testify/require" @@ -24,7 +25,7 @@ // GetInterestingTempDirectoryName returns interesting directory name used for testing. func GetInterestingTempDirectoryName() (string, error) { - td, err := os.MkdirTemp("", "kopia-test") + td, err := os.MkdirTemp("", "kopia-test-"+time.Now().UTC().Format("20060102-150405")) //nolint:forbidigo if err != nil { return "", errors.Wrap(err, "unable to create temp directory") } @@ -73,7 +74,7 @@ func TempDirectory(tb testing.TB) string { func TempDirectoryShort(tb testing.TB) string { tb.Helper() - d, err := os.MkdirTemp("", "kopia-test") + d, err := os.MkdirTemp("", "kopia-test-"+time.Now().UTC().Format("20060102-150405")) //nolint:forbidigo if err != nil { tb.Fatal(errors.Wrap(err, "unable to create temp directory")) }