Fix bridge tests
Summary:The `RCTDevMenu.hotLoadingAvailable` check always returned YES if `bridge.bundleURL` was nil. This caused the `setHotLoadingEnabled:` method to repeatedly reload the bridge, resulting in the following tests failing: `- [RCTBridgeTests testHookRegistration];` `- [RCTBridgeTests testCallNativeMethod];` Also, the `RUN_RUNLOOP_WHILE()` macro did not actually assert when timing out, and the logic in `- [RCTBridgeTests tearDown];` was broken in such a way that tests would always take 5 seconds to run (and then timeout silently). This adds an assertion, and removes the broken nil check for `jsExecutor`. Reviewed By: majak Differential Revision: D2988885 fb-gh-sync-id: 91307585ac8acb0181f0cddeeddf6cb4b198e4fe shipit-source-id: 91307585ac8acb0181f0cddeeddf6cb4b198e4fe
This commit is contained in:
parent
5a53d90003
commit
8d44c2db4f
|
@ -24,8 +24,12 @@
|
|||
#define RUN_RUNLOOP_WHILE(CONDITION) \
|
||||
{ \
|
||||
NSDate *timeout = [NSDate dateWithTimeIntervalSinceNow:5]; \
|
||||
while ((CONDITION) && [timeout timeIntervalSinceNow] > 0) { \
|
||||
while ((CONDITION)) { \
|
||||
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; \
|
||||
if ([timeout timeIntervalSinceNow] <= 0) { \
|
||||
XCTFail(@"Runloop timed out before condition was met"); \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
|
@ -140,9 +144,6 @@ RCT_EXPORT_MODULE(TestModule)
|
|||
|
||||
[_bridge invalidate];
|
||||
_bridge = nil;
|
||||
|
||||
RUN_RUNLOOP_WHILE(_jsExecutor != nil);
|
||||
XCTAssertNotNil(_jsExecutor);
|
||||
}
|
||||
|
||||
- (void)testHookRegistration
|
||||
|
|
|
@ -581,7 +581,7 @@ RCT_EXPORT_METHOD(reload)
|
|||
|
||||
- (BOOL)hotLoadingAvailable
|
||||
{
|
||||
return !_bridge.bundleURL.fileURL; // Only works when running from server
|
||||
return _bridge.bundleURL && !_bridge.bundleURL.fileURL; // Only works when running from server
|
||||
}
|
||||
|
||||
- (void)setHotLoadingEnabled:(BOOL)enabled
|
||||
|
|
Loading…
Reference in New Issue