Skip to content

Commit ce5ab7c

Browse files
committed
Garbage collect old test repositories before each run
1 parent 5e8f6ab commit ce5ab7c

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,21 @@ private static void SetUpTestEnvironment()
7272
SubmoduleTargetTestRepoWorkingDirPath = Path.Combine(sourceRelativePath, "submodule_target_wd");
7373
AssumeUnchangedRepoWorkingDirPath = Path.Combine(sourceRelativePath, "assume_unchanged_wd");
7474
SubmoduleSmallTestRepoWorkingDirPath = Path.Combine(sourceRelativePath, "submodule_small_wd");
75+
76+
CleanupTestReposOlderThan(TimeSpan.FromMinutes(15));
77+
}
78+
79+
private static void CleanupTestReposOlderThan(TimeSpan olderThan)
80+
{
81+
var oldTestRepos = new DirectoryInfo(Constants.TemporaryReposPath)
82+
.EnumerateDirectories()
83+
.Where(di => di.CreationTimeUtc < DateTimeOffset.Now.Subtract(olderThan))
84+
.Select(di => di.FullName);
85+
86+
foreach (var dir in oldTestRepos)
87+
{
88+
DirectoryHelper.DeleteDirectory(dir);
89+
}
7590
}
7691

7792
private static bool IsFileSystemCaseSensitiveInternal()

0 commit comments

Comments
 (0)