@@ -67,8 +67,12 @@ - (void)cleanUp {
67
67
68
68
#pragma mark Fixtures
69
69
70
+ - (NSString *)rootTempDirectory {
71
+ return [NSTemporaryDirectory () stringByAppendingPathComponent: @" com.libgit2.objectivegit" ];
72
+ }
73
+
70
74
- (void )setUpTempDirectoryPath {
71
- self.tempDirectoryPath = [[ NSTemporaryDirectory () stringByAppendingPathComponent: @" com.libgit2.objectivegit " ] stringByAppendingPathComponent: NSProcessInfo .processInfo.globallyUniqueString];
75
+ self.tempDirectoryPath = [self .rootTempDirectory stringByAppendingPathComponent: NSProcessInfo .processInfo.globallyUniqueString];
72
76
73
77
NSError *error = nil ;
74
78
BOOL success = [NSFileManager .defaultManager createDirectoryAtPath: self .tempDirectoryPath withIntermediateDirectories: YES attributes: nil error: &error];
@@ -87,9 +91,15 @@ - (void)setUpRepositoryFixtureIfNeeded:(NSString *)repositoryName {
87
91
88
92
NSString *zippedRepositoriesPath = [[NSBundle bundleForClass: self .class] pathForResource: @" fixtures" ofType: @" zip" ];
89
93
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);
93
103
}
94
104
95
105
- (NSString *)pathForFixtureRepositoryNamed : (NSString *)repositoryName {
@@ -138,7 +148,8 @@ - (BOOL)unzipFile:(NSString *)member fromArchiveAtPath:(NSString *)zipPath intoD
138
148
#pragma mark API
139
149
140
150
- (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 ];
142
153
XCTAssertNotNil (repository, @" Couldn't create a repository for %@ " , name);
143
154
return repository;
144
155
}
0 commit comments