From aa55b61b86e9c86f1b357cf2faa0660fe352ad4d Mon Sep 17 00:00:00 2001 From: Scott Kyle Date: Mon, 2 Nov 2015 13:32:49 -0800 Subject: [PATCH 1/4] Update React Native to 0.13.2 --- examples/ReactExample/package.json | 2 +- tests/ReactTests/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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/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:.." } From 7181a00f017d1f81fe4f9cb0e19886f7be4cad5a Mon Sep 17 00:00:00 2001 From: Scott Kyle Date: Mon, 2 Nov 2015 13:37:37 -0800 Subject: [PATCH 2/4] Fix to make RealmReact tests work in Chrome again Left the RealmReactChromeTests commented out for now until it's confirmed to work in the CI environment. --- .../ios/ReactTestsTests/RealmReactTests.m | 31 ++++++------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/tests/ReactTests/ios/ReactTestsTests/RealmReactTests.m b/tests/ReactTests/ios/ReactTestsTests/RealmReactTests.m index 70524cac..ad6ede0a 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"); } @@ -33,10 +36,7 @@ extern void JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(JSG + (id)currentExecutor { Class executorClass = [self executorClass]; - if (!executorClass) { - NSLog(@"%@: Executor class not found", self); - exit(1); - } + assert(executorClass); static RCTBridge *s_bridge; if (!s_bridge) { @@ -44,20 +44,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) { From 6c6931a97da2699d869ff47c3e12e903b0463c2b Mon Sep 17 00:00:00 2001 From: Ari Lazier Date: Mon, 2 Nov 2015 13:50:16 -0800 Subject: [PATCH 3/4] enable chrome tests --- tests/ReactTests/ios/ReactTestsTests/RealmReactTests.m | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/ReactTests/ios/ReactTestsTests/RealmReactTests.m b/tests/ReactTests/ios/ReactTestsTests/RealmReactTests.m index ad6ede0a..67ceb6d8 100644 --- a/tests/ReactTests/ios/ReactTestsTests/RealmReactTests.m +++ b/tests/ReactTests/ios/ReactTestsTests/RealmReactTests.m @@ -173,7 +173,6 @@ extern void JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(JSG @end -/* TODO: Re-enable once this works in CI @implementation RealmReactChromeTests + (Class)executorClass { @@ -185,4 +184,3 @@ extern void JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(JSG } @end - */ From 84b419c815d2d33f4b52114c9784739106d1cc74 Mon Sep 17 00:00:00 2001 From: Scott Kyle Date: Mon, 2 Nov 2015 15:20:45 -0800 Subject: [PATCH 4/4] Fix to run RealmReactTests with release builds In the case of a release build, React Native will not include the RCTWebSocketExecutor. --- .../ReactTests/ios/ReactTestsTests/RealmReactTests.m | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/ReactTests/ios/ReactTestsTests/RealmReactTests.m b/tests/ReactTests/ios/ReactTestsTests/RealmReactTests.m index 67ceb6d8..c703e7af 100644 --- a/tests/ReactTests/ios/ReactTestsTests/RealmReactTests.m +++ b/tests/ReactTests/ios/ReactTestsTests/RealmReactTests.m @@ -36,7 +36,9 @@ extern void JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(JSG + (id)currentExecutor { Class executorClass = [self executorClass]; - assert(executorClass); + if (!executorClass) { + return nil; + } static RCTBridge *s_bridge; if (!s_bridge) { @@ -63,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) { @@ -88,7 +96,6 @@ extern void JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(JSG testCaseNames = renamedTestCaseNames; } - XCTestSuite *suite = [super defaultTestSuite]; for (XCTestSuite *testSuite in [self testSuitesFromDictionary:testCaseNames]) { [suite addTest:testSuite]; }