From e94b116d7675399af719ac58e36d3274a23feea4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ramos?= Date: Mon, 6 May 2019 15:46:58 -0700 Subject: [PATCH] Support optional bundle prefix in RNTester integration tests Summary: Add support for a `CI_USE_BUNDLE_PREFIX` envvar in the RNTester Xcode scheme, as part of ongoing work to enable integration tests in Facebook's internal CI system. [iOS] [Added] - Add new envvar to support internal iOS tests at Facebook Reviewed By: cpojer Differential Revision: D15163397 fbshipit-source-id: 1b75b1868b5f9721a69f6cba4d4052be47e5e5e2 --- RNTester/RCTTest/RCTTestRunner.m | 6 +++++- .../xcshareddata/xcschemes/RNTester.xcscheme | 5 +++++ RNTester/RNTester/AppDelegate.mm | 15 ++++++++++----- .../RNTesterIntegrationTests/RCTLoggingTests.m | 6 +++++- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/RNTester/RCTTest/RCTTestRunner.m b/RNTester/RCTTest/RCTTestRunner.m index 74ae98d61..3e530a5e1 100644 --- a/RNTester/RCTTest/RCTTestRunner.m +++ b/RNTester/RCTTest/RCTTestRunner.m @@ -87,7 +87,11 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init) - (NSURL *)defaultScriptURL { if (getenv("CI_USE_PACKAGER") || _useBundler) { - return [NSURL URLWithString:[NSString stringWithFormat:@"http://localhost:8081/%@.bundle?platform=ios&dev=true", _appPath]]; + NSString *bundlePrefix = @""; + if (getenv("CI_USE_BUNDLE_PREFIX")) { + bundlePrefix = @"react-native-github/"; + } + return [NSURL URLWithString:[NSString stringWithFormat:@"http://localhost:8081/%@%@.bundle?platform=ios&dev=true", bundlePrefix, _appPath]]; } else { return [[NSBundle bundleForClass:[RCTBridge class]] URLForResource:@"main" withExtension:@"jsbundle"]; } diff --git a/RNTester/RNTester.xcodeproj/xcshareddata/xcschemes/RNTester.xcscheme b/RNTester/RNTester.xcodeproj/xcshareddata/xcschemes/RNTester.xcscheme index b3d01b135..4f65fc298 100644 --- a/RNTester/RNTester.xcodeproj/xcshareddata/xcschemes/RNTester.xcscheme +++ b/RNTester/RNTester.xcodeproj/xcshareddata/xcschemes/RNTester.xcscheme @@ -143,6 +143,11 @@ value = "1" isEnabled = "YES"> + + diff --git a/RNTester/RNTester/AppDelegate.mm b/RNTester/RNTester/AppDelegate.mm index 94c5933ef..4e11db008 100644 --- a/RNTester/RNTester/AppDelegate.mm +++ b/RNTester/RNTester/AppDelegate.mm @@ -67,21 +67,21 @@ _bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; - + // Appetizer.io params check NSDictionary *initProps = @{}; NSString *_routeUri = [[NSUserDefaults standardUserDefaults] stringForKey:@"route"]; if (_routeUri) { initProps = @{@"exampleFromAppetizeParams": [NSString stringWithFormat:@"rntester://example/%@Example", _routeUri]}; } - + #ifdef RN_FABRIC_ENABLED // FIXME: remove when resolved https://github.com/facebook/react-native/issues/23910 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleJavaScriptDidLoadNotification:) name:RCTJavaScriptDidLoadNotification object:_bridge]; - + _surfacePresenter = [[RCTSurfacePresenter alloc] initWithBridge:_bridge config:nil]; _bridge.surfacePresenter = _surfacePresenter; @@ -89,7 +89,7 @@ #else UIView *rootView = [[RCTRootView alloc] initWithBridge:_bridge moduleName:@"RNTesterApp" initialProperties:initProps]; #endif - + self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; UIViewController *rootViewController = [UIViewController new]; rootViewController.view = rootView; @@ -109,7 +109,12 @@ - (NSURL *)sourceURLForBridge:(__unused RCTBridge *)bridge { - return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"RNTester/js/RNTesterApp.ios" + NSString *bundlePrefix = @""; + if (getenv("CI_USE_BUNDLE_PREFIX")) { + bundlePrefix = @"react-native-github/"; + } + NSString *bundleRoot = [NSString stringWithFormat:@"%@RNTester/js/RNTesterApp.ios", bundlePrefix]; + return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:bundleRoot fallbackResource:nil]; } diff --git a/RNTester/RNTesterIntegrationTests/RCTLoggingTests.m b/RNTester/RNTesterIntegrationTests/RCTLoggingTests.m index ea631d344..8cc22ef0e 100644 --- a/RNTester/RNTesterIntegrationTests/RCTLoggingTests.m +++ b/RNTester/RNTesterIntegrationTests/RCTLoggingTests.m @@ -30,8 +30,12 @@ { NSURL *scriptURL; if (getenv("CI_USE_PACKAGER")) { + NSString *bundlePrefix = @""; + if (getenv("CI_USE_BUNDLE_PREFIX")) { + bundlePrefix = @"react-native-github/"; + } NSString *app = @"IntegrationTests/IntegrationTestsApp"; - scriptURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://localhost:8081/%@.bundle?platform=ios&dev=true", app]]; + scriptURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://localhost:8081/%@%@.bundle?platform=ios&dev=true", bundlePrefix, app]]; } else { scriptURL = [[NSBundle bundleForClass:[RCTBridge class]] URLForResource:@"main" withExtension:@"jsbundle"]; }