From 266ab7a0061c11c4da7ccde9e0d461c0d7331563 Mon Sep 17 00:00:00 2001 From: Chris Zheng Date: Sun, 12 Nov 2017 13:30:13 -0800 Subject: [PATCH] Pass scriptURL to RCTTestRunner Summary: Pass scriptURL to RCTTestRunner. If the scriptURL passed to RCTTestRunner is not nil, then RCTTestRunner will use it. else, RCTTestRunner will use whatever it has before. Differential Revision: D6215186 fbshipit-source-id: c3a5643021d60579fc8e60a69de150f6a4a39237 --- Libraries/RCTTest/RCTTestRunner.h | 8 +++++--- Libraries/RCTTest/RCTTestRunner.m | 8 +++++++- .../RCTRootViewIntegrationTests.m | 2 +- .../RNTesterIntegrationTests/RNTesterIntegrationTests.m | 2 +- RNTester/RNTesterIntegrationTests/RNTesterSnapshotTests.m | 2 +- 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Libraries/RCTTest/RCTTestRunner.h b/Libraries/RCTTest/RCTTestRunner.h index b1edad6a201811..9a50e94b2c9f13 100644 --- a/Libraries/RCTTest/RCTTestRunner.h +++ b/Libraries/RCTTest/RCTTestRunner.h @@ -32,10 +32,11 @@ * Use the RCTInitRunnerForApp macro for typical usage. See FBSnapshotTestCase.h for more information * on how to configure the snapshotting system. */ -#define RCTInitRunnerForApp(app__, moduleProvider__) \ +#define RCTInitRunnerForApp(app__, moduleProvider__, scriptURL__) \ [[RCTTestRunner alloc] initWithApp:(app__) \ referenceDirectory:@FB_REFERENCE_IMAGE_DIR \ - moduleProvider:(moduleProvider__)] + moduleProvider:(moduleProvider__) \ + scriptURL: scriptURL__] @protocol RCTBridgeModule; @class RCTBridge; @@ -68,7 +69,8 @@ */ - (instancetype)initWithApp:(NSString *)app referenceDirectory:(NSString *)referenceDirectory - moduleProvider:(RCTBridgeModuleListProvider)block NS_DESIGNATED_INITIALIZER; + moduleProvider:(RCTBridgeModuleListProvider)block + scriptURL:(NSURL *)scriptURL NS_DESIGNATED_INITIALIZER; /** * Simplest runTest function simply mounts the specified JS module with no diff --git a/Libraries/RCTTest/RCTTestRunner.m b/Libraries/RCTTest/RCTTestRunner.m index cb79087c321da7..836d7bb7762117 100644 --- a/Libraries/RCTTest/RCTTestRunner.m +++ b/Libraries/RCTTest/RCTTestRunner.m @@ -31,6 +31,7 @@ @implementation RCTTestRunner - (instancetype)initWithApp:(NSString *)app referenceDirectory:(NSString *)referenceDirectory moduleProvider:(RCTBridgeModuleListProvider)block + scriptURL:(NSURL *)scriptURL { RCTAssertParam(app); RCTAssertParam(referenceDirectory); @@ -46,7 +47,12 @@ - (instancetype)initWithApp:(NSString *)app _testController.referenceImagesDirectory = referenceDirectory; _moduleProvider = [block copy]; _appPath = app; - [self updateScript]; + + if (scriptURL != nil) { + _scriptURL = scriptURL; + } else { + [self updateScript]; + } } return self; } diff --git a/RNTester/RNTesterIntegrationTests/RCTRootViewIntegrationTests.m b/RNTester/RNTesterIntegrationTests/RCTRootViewIntegrationTests.m index 364a2b956202d4..fc015278359fdd 100644 --- a/RNTester/RNTesterIntegrationTests/RCTRootViewIntegrationTests.m +++ b/RNTester/RNTesterIntegrationTests/RCTRootViewIntegrationTests.m @@ -117,7 +117,7 @@ @implementation RCTRootViewIntegrationTests - (void)setUp { - _runner = RCTInitRunnerForApp(@"IntegrationTests/RCTRootViewIntegrationTestApp", nil); + _runner = RCTInitRunnerForApp(@"IntegrationTests/RCTRootViewIntegrationTestApp", nil, nil); } #pragma mark Logic Tests diff --git a/RNTester/RNTesterIntegrationTests/RNTesterIntegrationTests.m b/RNTester/RNTesterIntegrationTests/RNTesterIntegrationTests.m index 6a09c5e1ee5930..005d0e899ee371 100644 --- a/RNTester/RNTesterIntegrationTests/RNTesterIntegrationTests.m +++ b/RNTester/RNTesterIntegrationTests/RNTesterIntegrationTests.m @@ -37,7 +37,7 @@ @implementation RNTesterIntegrationTests - (void)setUp { - _runner = RCTInitRunnerForApp(@"IntegrationTests/IntegrationTestsApp", nil); + _runner = RCTInitRunnerForApp(@"IntegrationTests/IntegrationTestsApp", nil, nil); _runner.recordMode = NO; } diff --git a/RNTester/RNTesterIntegrationTests/RNTesterSnapshotTests.m b/RNTester/RNTesterIntegrationTests/RNTesterSnapshotTests.m index 8b369d4c01f7bc..4ba1e184a42422 100644 --- a/RNTester/RNTesterIntegrationTests/RNTesterSnapshotTests.m +++ b/RNTester/RNTesterIntegrationTests/RNTesterSnapshotTests.m @@ -24,7 +24,7 @@ @implementation RNTesterSnapshotTests - (void)setUp { - _runner = RCTInitRunnerForApp(@"RNTester/js/RNTesterApp.ios", nil); + _runner = RCTInitRunnerForApp(@"RNTester/js/RNTesterApp.ios", nil, nil); if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 11) { _runner.testSuffix = @"-iOS11"; } else if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 10) {