diff --git a/examples/ReactExample/package.json b/examples/ReactExample/package.json index 070e238b..74e20d96 100644 --- a/examples/ReactExample/package.json +++ b/examples/ReactExample/package.json @@ -6,7 +6,7 @@ "start": "node_modules/react-native/packager/packager.sh" }, "dependencies": { - "react-native": "0.13.0-rc", + "react-native": "0.13.2", "realm": "file:../../lib" } } diff --git a/tests/ReactTests/ios/ReactTestsTests/RealmReactTests.m b/tests/ReactTests/ios/ReactTestsTests/RealmReactTests.m index 70524cac..c703e7af 100644 --- a/tests/ReactTests/ios/ReactTestsTests/RealmReactTests.m +++ b/tests/ReactTests/ios/ReactTestsTests/RealmReactTests.m @@ -12,9 +12,6 @@ extern void JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(JSGlobalContextRef ctx, bool includesNativeCallStack); -@interface RCTDevMenu () -@end - @interface RealmReactTests : RealmJSTests @end @@ -23,6 +20,12 @@ extern void JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(JSG @implementation RealmReactTests ++ (void)load { + // We don't want the RCTDevMenu from switching the executor class from underneath us. + IMP init = class_getMethodImplementation([NSObject class], @selector(init)); + class_replaceMethod([RCTDevMenu class], @selector(init), init, NULL); +} + + (Class)executorClass { return NSClassFromString(@"RCTContextExecutor"); } @@ -34,8 +37,7 @@ extern void JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(JSG + (id)currentExecutor { Class executorClass = [self executorClass]; if (!executorClass) { - NSLog(@"%@: Executor class not found", self); - exit(1); + return nil; } static RCTBridge *s_bridge; @@ -44,20 +46,9 @@ extern void JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(JSG } if (!s_bridge.valid) { - NSNotification *notification = [self waitForNotification:RCTDidCreateNativeModules]; - s_bridge = notification.object; - - if (!s_bridge) { - NSLog(@"No RCTBridge provided by RCTJavaScriptDidLoadNotification"); - exit(1); - } - -#ifdef DEBUG - // We don't want the RCTDevMenu from switching the executor class from underneath us. - [s_bridge.devMenu invalidate]; -#endif - - [self waitForNotification:RCTJavaScriptDidLoadNotification]; + NSNotification *notification = [self waitForNotification:RCTJavaScriptDidLoadNotification]; + s_bridge = notification.userInfo[@"bridge"]; + assert(s_bridge); } if (s_bridge.executorClass != executorClass) { @@ -74,8 +65,14 @@ extern void JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(JSG } + (XCTestSuite *)defaultTestSuite { + XCTestSuite *suite = [super defaultTestSuite]; id 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! JSGlobalContextRef ctx = RealmReactGetJSGlobalContextForExecutor(executor, false); if (ctx) { @@ -99,7 +96,6 @@ extern void JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(JSG testCaseNames = renamedTestCaseNames; } - XCTestSuite *suite = [super defaultTestSuite]; for (XCTestSuite *testSuite in [self testSuitesFromDictionary:testCaseNames]) { [suite addTest:testSuite]; } @@ -184,7 +180,6 @@ extern void JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(JSG @end -/* TODO: Re-enable once this works in CI @implementation RealmReactChromeTests + (Class)executorClass { @@ -196,4 +191,3 @@ extern void JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(JSG } @end - */ diff --git a/tests/ReactTests/package.json b/tests/ReactTests/package.json index 7505c308..fc7c8c65 100644 --- a/tests/ReactTests/package.json +++ b/tests/ReactTests/package.json @@ -6,7 +6,7 @@ "start": "node_modules/react-native/packager/packager.sh" }, "dependencies": { - "react-native": "^0.13.0-rc", + "react-native": "0.13.2", "realm": "file:../../lib", "realm-tests": "file:.." }