diff --git a/oci/client/internal/fs/fs_test.go b/oci/client/internal/fs/fs_test.go index 66f8ea1d6..6940bd77c 100644 --- a/oci/client/internal/fs/fs_test.go +++ b/oci/client/internal/fs/fs_test.go @@ -41,7 +41,6 @@ func TestMain(m *testing.M) { } os.MkdirAll("testdata/symlinks", 0o755) - defer os.RemoveAll("testdata/symlinks") for _, sl := range symlinks { err := os.Symlink(sl.oldPath, sl.newPath) @@ -50,7 +49,13 @@ func TestMain(m *testing.M) { } } - os.Exit(m.Run()) + code := m.Run() + + err := os.RemoveAll("testdata/symlinks") + if err != nil { + panic(fmt.Errorf("unable to remove symlink directory: %v", err)) + } + os.Exit(code) } func TestRenameWithFallback(t *testing.T) {