From f3a6466fcdf8fb86fbc367f622e20271d83c0b7a Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Thu, 1 Oct 2015 04:19:46 -0700 Subject: [PATCH] Check if test runner is of right type before accessing its internals MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: I previously added this check to make the test complete waits until all teardown completed but if you're running tests with any other executor than the JSC one, this would crash. @​public Reviewed By: @jspahrsummers Differential Revision: D2493967 --- Libraries/RCTTest/RCTTestRunner.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Libraries/RCTTest/RCTTestRunner.m b/Libraries/RCTTest/RCTTestRunner.m index 41316360b..0da2c8388 100644 --- a/Libraries/RCTTest/RCTTestRunner.m +++ b/Libraries/RCTTest/RCTTestRunner.m @@ -15,6 +15,7 @@ #import "RCTRootView.h" #import "RCTTestModule.h" #import "RCTUtils.h" +#import "RCTContextExecutor.h" static const NSTimeInterval kTestTimeoutSeconds = 60; static const NSTimeInterval kTestTeardownTimeoutSeconds = 30; @@ -114,7 +115,10 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init) // Take a weak reference to the JS context, so we track its deallocation later // (we can only do this now, since it's been lazily initialized) - weakJSContext = [[[bridge valueForKey:@"batchedBridge"] valueForKey:@"javaScriptExecutor"] valueForKey:@"context"]; + id jsExecutor = [bridge valueForKeyPath:@"batchedBridge.javaScriptExecutor"]; + if ([jsExecutor isKindOfClass:[RCTContextExecutor class]]) { + weakJSContext = [jsExecutor valueForKey:@"context"]; + } [rootView removeFromSuperview]; RCTSetLogFunction(RCTDefaultLogFunction);