8000 Garbage collect old test repositories before each run · libgit2/libgit2sharp@cca5705 · GitHub
[go: up one dir, main page]

Skip to content

Commit cca5705

Browse files
committed
Garbage collect old test repositories before each run
1 parent 8115ef6 commit cca5705

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,20 @@ 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).EnumerateDirectories("*")
82+
.Where(di => di.CreationTimeUtc < DateTimeOffset.Now.Subtract(olderThan))
83+
.Select(di => di.FullName);
84+
85+
foreach (var dir in oldTestRepos)
86+
{
87+
DirectoryHelper.DeleteDirectory(dir);
88+
}
7589
}
7690

7791
private static bool IsFileSystemCaseSensitiveInternal()

0 commit comments

Comments
 (0)
0