Guard against possible race conditions in RCTAllocationTests

Reviewed By: javache

Differential Revision: D3829341

fbshipit-source-id: 2a3fd66a7b1494176726a79ef28cef5158d8ad58
This commit is contained in:
Alex Kotliarskyi 2016-09-08 15:00:51 -07:00 committed by Facebook Github Bot 8
parent e70d1dba58
commit f1c158e534
1 changed files with 7 additions and 2 deletions

View File

@ -85,9 +85,14 @@ RCT_EXPORT_METHOD(test:(__unused NSString *)a
NSURL *tempDir = [NSURL fileURLWithPath:NSTemporaryDirectory() isDirectory:YES];
[[NSFileManager defaultManager] createDirectoryAtURL:tempDir withIntermediateDirectories:YES attributes:nil error:NULL];
NSString *guid = [[NSProcessInfo processInfo] globallyUniqueString];
NSString *fileName = [NSString stringWithFormat:@"rctallocationtests-bundle-%@.js", guid];
_bundleURL = [tempDir URLByAppendingPathComponent:@"rctallocationtests-bundle.js"];
[bundleContents writeToURL:_bundleURL atomically:YES encoding:NSUTF8StringEncoding error:NULL];
_bundleURL = [tempDir URLByAppendingPathComponent:fileName];
NSError *saveError;
if (![bundleContents writeToURL:_bundleURL atomically:YES encoding:NSUTF8StringEncoding error:&saveError]) {
XCTFail(@"Failed to save test bundle to %@, error: %@", _bundleURL, saveError);
};
}
- (void)tearDown