forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobjc-test.sh
executable file
·93 lines (76 loc) · 2.79 KB
/
objc-test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash
set -ex
# Script used to run iOS and tvOS tests.
# Environment variables are used to configure what test to run.
# If not arguments are passed to the script, it will only compile
# the RNTester.
# If the script is called with a single argument "test", we'll
# also run the RNTester integration test (needs JS and packager).
# ./objc-test.sh test
SCRIPTS=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
ROOT=$(dirname $SCRIPTS)
cd $ROOT
# Create cleanup handler
function cleanup {
EXIT_CODE=$?
set +e
if [ $EXIT_CODE -ne 0 ];
then
WATCHMAN_LOGS=/usr/local/Cellar/watchman/3.1/var/run/watchman/$USER.log
[ -f $WATCHMAN_LOGS ] && cat $WATCHMAN_LOGS
fi
# kill whatever is occupying port 8081 (packager)
lsof -i tcp:8081 | awk 'NR!=1 {print $2}' | xargs kill
# kill whatever is occupying port 5555 (web socket server)
lsof -i tcp:5555 | awk 'NR!=1 {print $2}' | xargs kill
}
trap cleanup EXIT
# Wait for the package to start
function waitForPackager {
local -i max_attempts=60
local -i attempt_num=1
until $(curl -s http://localhost:8081/status | grep "packager-status:running" -q); do
if (( attempt_num == max_attempts )); then
echo "Packager did not respond in time. No more attempts left."
exit 1
else
(( attempt_num++ ))
echo "Packager did not respond. Retrying for attempt number $attempt_num..."
sleep 1
fi
done
echo "Packager is ready!"
}
# If first argument is "test", actually start the packager and run tests.
# Otherwise, just build RNTester for tvOS and exit
if [ "$1" = "test" ]; then
# Start the packager
./scripts/packager.sh --max-workers=1 || echo "Can't start packager automatically" &
# Start the WebSocket test server
open "./IntegrationTests/launchWebSocketServer.command" || echo "Can't start web socket server automatically"
waitForPackager
# Preload the RNTesterApp bundle for better performance in integration tests
curl 'http://localhost:8081/RNTester/js/RNTesterApp.ios.bundle?platform=ios&dev=true' -o temp.bundle
rm temp.bundle
curl 'http://localhost:8081/RNTester/js/RNTesterApp.ios.bundle?platform=ios&dev=true&minify=false' -o temp.bundle
rm temp.bundle
curl 'http://localhost:8081/IntegrationTests/IntegrationTestsApp.bundle?platform=ios&dev=true' -o temp.bundle
rm temp.bundle
curl 'http://localhost:8081/IntegrationTests/RCTRootViewIntegrationTestApp.bundle?platform=ios&dev=true' -o temp.bundle
rm temp.bundle
# Run tests
xcodebuild \
-project "RNTester/RNTester.xcodeproj" \
-scheme $SCHEME \
-sdk $SDK \
-destination "$DESTINATION" \
build test \
| xcpretty --report junit --output ~/react-native/reports/junit/objc-xcodebuild-results.xml
else
# Don't run tests. No need to pass -destination to xcodebuild.
xcodebuild \
-project "RNTester/RNTester.xcodeproj" \
-scheme $SCHEME \
-sdk $SDK \
build
fi