Merge RCTPlatform.isTesting and RCTRunningInTestEnvironment

Reviewed By: fkgozali

Differential Revision: D4802834

fbshipit-source-id: 76bb98877f2fc427c01806b192d8dc71489a1c4a
This commit is contained in:
Pieter De Baets 2017-03-30 09:53:51 -07:00 committed by Facebook Github Bot
parent 5af30382d5
commit f6754348be
2 changed files with 6 additions and 10 deletions

View File

@ -30,11 +30,6 @@ static NSString *interfaceIdiom(UIUserInterfaceIdiom idiom) {
}
}
static BOOL isTestingEnvironment(void) {
NSDictionary *environment = [[NSProcessInfo processInfo] environment];
return [environment[@"IS_TESTING"] boolValue];
}
RCT_EXPORT_MODULE(PlatformConstants)
- (NSDictionary<NSString *, id> *)constantsToExport
@ -45,7 +40,7 @@ RCT_EXPORT_MODULE(PlatformConstants)
@"osVersion": [device systemVersion],
@"systemName": [device systemName],
@"interfaceIdiom": interfaceIdiom([device userInterfaceIdiom]),
@"isTesting": @(isTestingEnvironment()),
@"isTesting": @(RCTRunningInTestEnvironment()),
};
}

View File

@ -9,17 +9,16 @@
#import "RCTUtils.h"
#import <dlfcn.h>
#import <mach/mach_time.h>
#import <objc/message.h>
#import <objc/runtime.h>
#import <zlib.h>
#import <UIKit/UIKit.h>
#import <CommonCrypto/CommonCrypto.h>
#import <zlib.h>
#import <dlfcn.h>
#import "RCTAssert.h"
#import "RCTLog.h"
@ -445,7 +444,9 @@ BOOL RCTRunningInTestEnvironment(void)
static BOOL isTestEnvironment = NO;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
isTestEnvironment = objc_lookUpClass("SenTestCase") || objc_lookUpClass("XCTest");
NSDictionary *environment = [[NSProcessInfo processInfo] environment];
isTestEnvironment = objc_lookUpClass("SenTestCase") || objc_lookUpClass("XCTest") ||
[environment[@"IS_TESTING"] boolValue];
});
return isTestEnvironment;
}