Skip to content

Commit 64282fd

Browse files
djsisonfacebook-github-bot
authored andcommitted
Revert D15958209: [RN] [RNTesterPods 5] Use CocoaPods-based RNTesterPods for iOS tests
Differential Revision: D15958209 Original commit changeset: b51fb907812c fbshipit-source-id: f0c499d8720ac91d5933c560281788e123269478
1 parent 39ab667 commit 64282fd

32 files changed

+297
-1094
lines changed

.circleci/config.yml

Lines changed: 96 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ executors:
3434
reactnativeios:
3535
<<: *defaults
3636
macos:
37-
xcode: "10.2.1"
37+
xcode: "10.2.0"
3838

3939
# -------------------------
4040
# COMMANDS
@@ -117,21 +117,6 @@ commands:
117117
- ~/Library/Caches/Homebrew
118118
key: v1-brew
119119

120-
with_pods_cache_span:
121-
parameters:
122-
steps:
123-
type: steps
124-
steps:
125-
- restore_cache:
126-
keys:
127-
- v1-pods-{{ checksum "RNTester/Podfile.lock" }}
128-
- v1-pods-
129-
- steps: << parameters.steps >>
130-
- save_cache:
131-
paths:
132-
- RNTester/Pods
133-
key: v1-pods-{{ checksum "RNTester/Podfile.lock" }}
134-
135120
download_gradle_dependencies:
136121
steps:
137122
- restore_cache:
@@ -309,31 +294,111 @@ jobs:
309294
- setup_artifacts
310295
- run_yarn
311296

312-
- run: |
313-
cd RNTester
314-
bundle check || bundle install
315297
- run:
316-
name: Boot iPhone Simulator
317-
command: source scripts/.tests.env && xcrun simctl boot "$IOS_DEVICE" || true
298+
name: Print Xcode environment
299+
command: xcodebuild -version
318300

319301
- run:
320-
name: Fetch CocoaPods Specs
321-
command: |
322-
curl https://cocoapods-specs.circleci.com/fetch-cocoapods-repo-from-s3.sh | bash -s cf
302+
name: List available devices
303+
command: instruments -s devices
323304

324-
- with_pods_cache_span:
325-
steps:
326-
- run:
327-
name: Generate RNTesterPods Workspace
328-
command: cd RNTester && pod install --verbose
305+
- run:
306+
name: Boot iOS Simulator
307+
command: source scripts/.tests.env && xcrun simctl boot "$IOS_DEVICE" || true
329308

330309
- with_brew_cache_span:
331310
steps:
332311
- brew_install:
333312
package: watchman
334313
- run: touch .watchmanconfig
335314

336-
- run: yarn test-ios
315+
- run:
316+
name: Start Metro packager
317+
command: yarn start --max-workers=1 || echo "Can't start packager automatically"
318+
background: true
319+
320+
- run:
321+
name: Start WebSocket test server
322+
command: open "./IntegrationTests/launchWebSocketServer.command" || echo "Can't start web socket server automatically"
323+
background: true
324+
325+
- run:
326+
name: Verify RNTester can be built
327+
command: |
328+
source ./scripts/.tests.env
329+
xcodebuild \
330+
-project RNTester/RNTester.xcodeproj \
331+
-scheme RNTester \
332+
-sdk iphonesimulator \
333+
-destination "platform=iOS Simulator,name=$IOS_DEVICE,OS=$IOS_TARGET_OS" \
334+
-UseModernBuildSystem=NO \
335+
build | \
336+
xcpretty --report junit --output "$REPORTS_DIR/junit/ios_buiild/results.xml" && \
337+
exit "${PIPESTATUS[0]}"
338+
339+
- run:
340+
name: Wait for Metro packager
341+
command: |
342+
max_attempts=60
343+
attempt_num=1
344+
until curl -s http://localhost:8081/status | grep "packager-status:running" -q; do
345+
if (( attempt_num == max_attempts )); then
346+
echo "Packager did not respond in time. No more attempts left."
347+
exit 1
348+
else
349+
(( attempt_num++ ))
350+
echo "Packager did not respond. Retrying for attempt number $attempt_num..."
351+
sleep 1
352+
fi
353+
done
354+
echo "Packager is ready!"
355+
356+
- run:
357+
name: Preload the RNTesterApp bundles
358+
command: |
359+
curl --silent 'http://localhost:8081/RNTester/js/RNTesterApp.ios.bundle?platform=ios&dev=true' --output /dev/null
360+
curl --silent 'http://localhost:8081/RNTester/js/RNTesterApp.ios.bundle?platform=ios&dev=true&minify=false' --output /dev/null
361+
curl --silent 'http://localhost:8081/IntegrationTests/IntegrationTestsApp.bundle?platform=ios&dev=true' --output /dev/null
362+
curl --silent 'http://localhost:8081/IntegrationTests/RCTRootViewIntegrationTestApp.bundle?platform=ios&dev=true' --output /dev/null
363+
364+
- run:
365+
name: Run RNTester Unit Tests
366+
command: |
367+
source ./scripts/.tests.env
368+
xcodebuild \
369+
-project RNTester/RNTester.xcodeproj \
370+
-scheme RNTester \
371+
-sdk iphonesimulator \
372+
-destination "platform=iOS Simulator,name=$IOS_DEVICE,OS=$IOS_TARGET_OS" \
373+
-UseModernBuildSystem=NO \
374+
-only-testing:RNTesterUnitTests \
375+
build test | \
376+
xcpretty --report junit --output "$REPORTS_DIR/junit/ios_unit_tests/results.xml" && \
377+
exit "${PIPESTATUS[0]}"
378+
379+
- run:
380+
name: Run RNTester Integration Tests
381+
command: |
382+
source ./scripts/.tests.env
383+
xcodebuild \
384+
-project RNTester/RNTester.xcodeproj \
385+
-scheme RNTester \
386+
-sdk iphonesimulator \
387+
-destination "platform=iOS Simulator,name=$IOS_DEVICE,OS=$IOS_TARGET_OS" \
388+
-UseModernBuildSystem=NO \
389+
-only-testing:RNTesterIntegrationTests \
390+
build test | \
391+
xcpretty --report junit --output "$REPORTS_DIR/junit/ios_integration_tests/results.xml" && \
392+
exit "${PIPESTATUS[0]}"
393+
394+
- run:
395+
name: Stop Metro packager and WebSocket test server
396+
command: |
397+
# kill whatever is occupying port 8081 (packager)
398+
lsof -i tcp:8081 | awk 'NR!=1 {print $2}' | xargs kill
399+
# kill whatever is occupying port 5555 (web socket server)
400+
lsof -i tcp:5555 | awk 'NR!=1 {print $2}' | xargs kill
401+
337402
- store_test_results:
338403
path: ~/reports/junit
339404

@@ -366,6 +431,7 @@ jobs:
366431
package: applesimutils
367432
- brew_install:
368433
package: watchman
434+
369435
# Configure Watchman
370436
- run: touch .watchmanconfig
371437

RNTester/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Pods/

RNTester/Gemfile

Lines changed: 0 additions & 4 deletions
This file was deleted.

RNTester/Podfile

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ platform :ios, '9.0'
22

33
require_relative '../scripts/autolink-ios'
44

5-
def pods()
5+
target 'RNTester' do
66
# Uncomment for Swift
77
# use_frameworks!
88

@@ -21,23 +21,3 @@ def pods()
2121
# To use fabric: add `fabric_enabled` option to the use_react_native method above, like below
2222
# use_react_native!(path: "..", turbo_modules_enabled: true, fabric_enabled: true)
2323
end
24-
25-
target 'RNTester' do
26-
pods()
27-
end
28-
29-
target 'RNTesterUnitTests' do
30-
pods()
31-
pod 'React-RCTTest', :path => "RCTTest"
32-
end
33-
34-
target 'RNTesterIntegrationTests' do
35-
pods()
36-
pod 'React-RCTTest', :path => "RCTTest"
37-
end
38-
39-
post_install do |installer|
40-
installer.pods_project.targets.each do |target|
41-
puts target.name
42-
end
43-
end

RNTester/README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,18 @@ Before running the app, make sure you ran:
1414

1515
Both macOS and Xcode are required.
1616

17-
- Install CocoaPods. We installing CocoaPods using [Homebrew](http://brew.sh/): `brew install cocoapods`
17+
- Open `RNTester/RNTester.xcodeproj` in Xcode
18+
- Hit the Run button
19+
20+
See [Running on device](https://facebook.github.io/react-native/docs/running-on-device.html) if you want to use a physical device.
21+
22+
### Running on iOS with CocoaPods
23+
24+
Similar to above, you can build the app via Xcode with help of CocoaPods.
25+
26+
- Install [CocoaPods](http://facebook.github.io/react-native/docs/integration-with-existing-apps.html#3-install-cocoapods)
1827
- Run `cd RNTester; pod install`
19-
- Open the generated `RNTesterPods.xcworkspace`. This is not checked in, as it is generated by CocoaPods. Do not open `RNTesterPods.xcodeproj` directly.
28+
- Open the generated `RNTesterPods.xcworkspace` (this is not checked in). Do not open `RNTesterPods.xcodeproj` directly.
2029

2130
### Running on Android
2231

RNTester/RNTesterIntegrationTests/Info.plist

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<plist version="1.0">
44
<dict>
55
<key>CFBundleDevelopmentRegion</key>
6-
<string>$(DEVELOPMENT_LANGUAGE)</string>
6+
<string>en</string>
77
<key>CFBundleExecutable</key>
88
<string>$(EXECUTABLE_NAME)</string>
99
<key>CFBundleIdentifier</key>
@@ -16,6 +16,8 @@
1616
<string>BNDL</string>
1717
<key>CFBundleShortVersionString</key>
1818
<string>1.0</string>
19+
<key>CFBundleSignature</key>
20+
<string>????</string>
1921
<key>CFBundleVersion</key>
2022
<string>1</string>
2123
</dict>

RNTester/RNTesterIntegrationTests/RCTRootViewIntegrationTests.m

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,10 @@
99
#import <UIKit/UIKit.h>
1010
#import <XCTest/XCTest.h>
1111

12-
#if (defined(COCOAPODS))
13-
#import <React-RCTTest/React/RCTTestRunner.h>
14-
#import <React-Core/React/RCTEventDispatcher.h>
15-
#import <React-Core/React/RCTRootView.h>
16-
#import <React-Core/React/RCTRootViewDelegate.h>
17-
#else
1812
#import <RCTTest/RCTTestRunner.h>
1913
#import <React/RCTEventDispatcher.h>
2014
#import <React/RCTRootView.h>
2115
#import <React/RCTRootViewDelegate.h>
22-
#endif
2316

2417
#define RCT_TEST_DATA_CONFIGURATION_BLOCK(appName, testType, input, block) \
2518
- (void)DISABLED_test##appName##_##testType##_##input \

RNTester/RNTesterIntegrationTests/RNTesterIntegrationTests.m

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@
88
#import <UIKit/UIKit.h>
99
#import <XCTest/XCTest.h>
1010

11-
#if (defined(COCOAPODS))
12-
#import <React-RCTTest/React/RCTTestRunner.h>
13-
#else
1411
#import <RCTTest/RCTTestRunner.h>
15-
#endif
1612

1713
#define RCT_TEST(name) \
1814
- (void)test##name \
@@ -80,4 +76,3 @@ - (void)testTheTester_waitOneFrame
8076
RCT_TEST(AccessibilityManagerTest)
8177

8278
@end
83-

RNTester/RNTesterIntegrationTests/RNTesterSnapshotTests.m

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@
99
#import <UIKit/UIKit.h>
1010
#import <XCTest/XCTest.h>
1111

12-
#if (defined(COCOAPODS))
13-
#import <React-RCTTest/React/RCTTestRunner.h>
14-
#else
1512
#import <RCTTest/RCTTestRunner.h>
16-
#endif
1713

1814
@interface RNTesterSnapshotTests : XCTestCase
1915
{

0 commit comments

Comments
 (0)