Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion ObjectiveGitTests/QuickSpec+GTFixtures.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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];

Expand All @@ -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];
Expand Down
Loading