@@ -67,8 +67,12 @@ - (void)cleanUp {
6767
6868#pragma mark Fixtures
6969
70+ - (NSString *)rootTempDirectory {
71+ return [NSTemporaryDirectory () stringByAppendingPathComponent: @" com.libgit2.objectivegit" ];
72+ }
73+
7074- (void )setUpTempDirectoryPath {
71- self.tempDirectoryPath = [[ NSTemporaryDirectory () stringByAppendingPathComponent: @" com.libgit2.objectivegit " ] stringByAppendingPathComponent: NSProcessInfo .processInfo.globallyUniqueString];
75+ self.tempDirectoryPath = [self .rootTempDirectory stringByAppendingPathComponent: NSProcessInfo .processInfo.globallyUniqueString];
7276
7377 NSError *error = nil ;
7478 BOOL success = [NSFileManager .defaultManager createDirectoryAtPath: self .tempDirectoryPath withIntermediateDirectories: YES attributes: nil error: &error];
@@ -87,9 +91,15 @@ - (void)setUpRepositoryFixtureIfNeeded:(NSString *)repositoryName {
8791
8892 NSString *zippedRepositoriesPath = [[NSBundle bundleForClass: self .class] pathForResource: @" fixtures" ofType: @" zip" ];
8993
90- error = nil ;
91- success = [self unzipFile: repositoryName fromArchiveAtPath: zippedRepositoriesPath intoDirectory: self .repositoryFixturesPath error: &error];
92- XCTAssertTrue (success, @" Couldn't unzip fixture \" %@ \" from %@ to %@ : %@ " , repositoryName, zippedRepositoriesPath, self.repositoryFixturesPath , error);
94+ NSString *cleanRepositoryPath = [self .rootTempDirectory stringByAppendingPathComponent: @" clean_repository" ];
95+ if (![NSFileManager .defaultManager fileExistsAtPath: cleanRepositoryPath isDirectory: nil ]) {
96+ error = nil ;
97+ success = [self unzipFile: repositoryName fromArchiveAtPath: zippedRepositoriesPath intoDirectory: cleanRepositoryPath error: &error];
98+ XCTAssertTrue (success, @" Couldn't unzip fixture \" %@ \" from %@ to %@ : %@ " , repositoryName, zippedRepositoriesPath, cleanRepositoryPath, error);
99+ }
100+
101+ success = [[NSFileManager defaultManager ] copyItemAtPath: [cleanRepositoryPath stringByAppendingPathComponent: repositoryName] toPath: path error: &error];
102+ XCTAssertTrue (success, @" Couldn't copy directory %@ " , error);
93103}
94104
95105- (NSString *)pathForFixtureRepositoryNamed : (NSString *)repositoryName {
@@ -138,7 +148,8 @@ - (BOOL)unzipFile:(NSString *)member fromArchiveAtPath:(NSString *)zipPath intoD
138148#pragma mark API
139149
140150- (GTRepository *)fixtureRepositoryNamed : (NSString *)name {
141- GTRepository *repository = [[GTRepository alloc ] initWithURL: [NSURL fileURLWithPath: [self pathForFixtureRepositoryNamed: name]] error: NULL ];
151+ NSURL *url = [NSURL fileURLWithPath: [self pathForFixtureRepositoryNamed: name]];
152+ GTRepository *repository = [[GTRepository alloc ] initWithURL: url error: NULL ];
142153 XCTAssertNotNil (repository, @" Couldn't create a repository for %@ " , name);
143154 return repository;
144155}
0 commit comments