From ad8625acd90e671ea757317550b7e08bc75acfdb Mon Sep 17 00:00:00 2001 From: Gonen Date: Tue, 29 Sep 2026 23:11:08 +0300 Subject: [PATCH] Give each test process its own fixture extraction The unzipped fixtures were cached in one clean_repository directory shared by every test run on the machine, so concurrent runs from different checkouts collided, and a run reused whatever fixtures.zip another branch had extracted before it. - Unzip into clean_repository- once per test process, the same no-shared-state approach GitX's own tests use for temp folders. - Remove that directory when the process exits. Co-Authored-By: Claude Opus 5.5 --- ObjectiveGitTests/QuickSpec+GTFixtures.m | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/ObjectiveGitTests/QuickSpec+GTFixtures.m b/ObjectiveGitTests/QuickSpec+GTFixtures.m index 557273a3..86192e34 100644 --- a/ObjectiveGitTests/QuickSpec+GTFixtures.m +++ b/ObjectiveGitTests/QuickSpec+GTFixtures.m @@ -16,6 +16,12 @@ static NSString * const FixturesErrorDomain = @"com.objectivegit.Fixtures"; +static NSString *processCleanRepositoryPath; + +static void removeCleanRepository(void) { + [NSFileManager.defaultManager removeItemAtPath:processCleanRepositoryPath error:NULL]; +} + @interface QuickSpec (Fixtures) @property (nonatomic, readonly, copy) NSString *repositoryFixturesPath; @@ -69,6 +75,15 @@ - (NSString *)rootTempDirectory { return [NSTemporaryDirectory() stringByAppendingPathComponent:@"com.libgit2.objectivegit"]; } +- (NSString *)cleanRepositoryPath { + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + processCleanRepositoryPath = [self.rootTempDirectory stringByAppendingPathComponent:[@"clean_repository-" stringByAppendingString:NSProcessInfo.processInfo.globallyUniqueString]]; + atexit(removeCleanRepository); + }); + return processCleanRepositoryPath; +} + - (void)setUpTempDirectoryPath { self.tempDirectoryPath = [self.rootTempDirectory stringByAppendingPathComponent:NSProcessInfo.processInfo.globallyUniqueString]; @@ -89,7 +104,7 @@ - (void)setUpRepositoryFixtureIfNeeded:(NSString *)repositoryName { NSString *zippedRepositoriesPath = [[NSBundle bundleForClass:self.class] pathForResource:@"fixtures" ofType:@"zip"]; - NSString *cleanRepositoryPath = [self.rootTempDirectory stringByAppendingPathComponent:@"clean_repository"]; + NSString *cleanRepositoryPath = self.cleanRepositoryPath; if (![NSFileManager.defaultManager fileExistsAtPath:cleanRepositoryPath isDirectory:nil]) { error = nil; success = [self unzipFromArchiveAtPath:zippedRepositoriesPath intoDirectory:cleanRepositoryPath error:&error];