Fix to run RealmReactTests with release builds

In the case of a release build, React Native will not include the RCTWebSocketExecutor.
This commit is contained in:
Scott Kyle 2015-11-02 15:20:45 -08:00
parent 6c6931a97d
commit 84b419c815
1 changed files with 9 additions and 2 deletions

View File

@ -36,7 +36,9 @@ extern void JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(JSG
+ (id<RCTJavaScriptExecutor>)currentExecutor { + (id<RCTJavaScriptExecutor>)currentExecutor {
Class executorClass = [self executorClass]; Class executorClass = [self executorClass];
assert(executorClass); if (!executorClass) {
return nil;
}
static RCTBridge *s_bridge; static RCTBridge *s_bridge;
if (!s_bridge) { if (!s_bridge) {
@ -63,8 +65,14 @@ extern void JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(JSG
} }
+ (XCTestSuite *)defaultTestSuite { + (XCTestSuite *)defaultTestSuite {
XCTestSuite *suite = [super defaultTestSuite];
id<RCTJavaScriptExecutor> executor = [self currentExecutor]; id<RCTJavaScriptExecutor> executor = [self currentExecutor];
// The executor may be nil if the executorClass was not found (i.e. release build).
if (!executor) {
return suite;
}
// FIXME: Remove this nonsense once the crashes go away when a test fails! // FIXME: Remove this nonsense once the crashes go away when a test fails!
JSGlobalContextRef ctx = RealmReactGetJSGlobalContextForExecutor(executor, false); JSGlobalContextRef ctx = RealmReactGetJSGlobalContextForExecutor(executor, false);
if (ctx) { if (ctx) {
@ -88,7 +96,6 @@ extern void JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(JSG
testCaseNames = renamedTestCaseNames; testCaseNames = renamedTestCaseNames;
} }
XCTestSuite *suite = [super defaultTestSuite];
for (XCTestSuite *testSuite in [self testSuitesFromDictionary:testCaseNames]) { for (XCTestSuite *testSuite in [self testSuitesFromDictionary:testCaseNames]) {
[suite addTest:testSuite]; [suite addTest:testSuite];
} }