2016-10-16 22:37:45 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -ex
|
|
|
|
|
|
|
|
SCRIPTS=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
2017-03-08 19:33:35 +00:00
|
|
|
ROOT=$(dirname "$SCRIPTS")
|
2016-10-16 22:37:45 +00:00
|
|
|
|
2017-03-08 19:33:35 +00:00
|
|
|
cd "$ROOT"
|
2016-10-16 22:37:45 +00:00
|
|
|
|
2017-03-06 22:10:07 +00:00
|
|
|
# Create cleanup handler
|
|
|
|
function cleanup {
|
|
|
|
EXIT_CODE=$?
|
|
|
|
set +e
|
2016-10-16 22:37:45 +00:00
|
|
|
|
2017-03-06 22:10:07 +00:00
|
|
|
if [ $EXIT_CODE -ne 0 ];
|
|
|
|
then
|
|
|
|
WATCHMAN_LOGS=/usr/local/Cellar/watchman/3.1/var/run/watchman/$USER.log
|
2017-03-08 19:33:35 +00:00
|
|
|
[ -f "$WATCHMAN_LOGS" ] && cat "$WATCHMAN_LOGS"
|
2017-03-06 22:10:07 +00:00
|
|
|
fi
|
2017-03-09 11:09:21 +00:00
|
|
|
# kill backgrounded jobs
|
|
|
|
# shellcheck disable=SC2046
|
|
|
|
kill $(jobs -p)
|
2017-03-06 22:10:07 +00:00
|
|
|
# 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
|
|
|
|
}
|
2017-03-09 11:09:21 +00:00
|
|
|
trap cleanup INT TERM EXIT
|
2017-03-06 22:10:07 +00:00
|
|
|
|
2017-03-16 22:18:20 +00:00
|
|
|
# If first argument is "test", actually start the packager and run tests.
|
|
|
|
# Otherwise, just build UIExplorer for tvOS and exit
|
|
|
|
|
|
|
|
if [ "$1" = "test" ];
|
|
|
|
then
|
|
|
|
|
2017-03-08 19:33:35 +00:00
|
|
|
# Start the packager
|
|
|
|
(exec "./packager/launchPackager.command" || echo "Can't start packager automatically") &
|
|
|
|
(exec "./IntegrationTests/launchWebSocketServer.command" || echo "Can't start web socket server automatically") &
|
|
|
|
|
|
|
|
# wait until packager is ready
|
|
|
|
PACKAGER_IS_RUNNING="packager-status:running"
|
|
|
|
SECONDS=0
|
|
|
|
STATUS=
|
|
|
|
|
|
|
|
sleep 2
|
|
|
|
test "$SECONDS" -ne 0 # Make sure the magic $SECONDS variable works
|
|
|
|
|
|
|
|
set +ex
|
|
|
|
while [ "$STATUS" != "$PACKAGER_IS_RUNNING" ] && [ "$SECONDS" -lt 60 ]; do
|
|
|
|
STATUS=$(curl --silent 'http://localhost:8081/status')
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
set -ex
|
|
|
|
|
|
|
|
if [ "$STATUS" != "$PACKAGER_IS_RUNNING" ]; then
|
|
|
|
echo "Could not startup packager within $SECONDS seconds"
|
|
|
|
false
|
|
|
|
fi
|
2017-03-06 22:10:07 +00:00
|
|
|
|
|
|
|
# Preload the UIExplorerApp bundle for better performance in integration tests
|
|
|
|
curl 'http://localhost:8081/Examples/UIExplorer/js/UIExplorerApp.ios.bundle?platform=ios&dev=true' -o temp.bundle
|
|
|
|
rm temp.bundle
|
|
|
|
curl 'http://localhost:8081/Examples/UIExplorer/js/UIExplorerApp.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
|
|
|
|
|
2017-03-16 22:18:20 +00:00
|
|
|
# Build and test for iOS
|
2017-03-06 22:10:07 +00:00
|
|
|
# TODO: We use xcodebuild because xctool would stall when collecting info about
|
|
|
|
# the tests before running them. Switch back when this issue with xctool has
|
|
|
|
# been resolved.
|
|
|
|
xcodebuild \
|
|
|
|
-project "Examples/UIExplorer/UIExplorer.xcodeproj" \
|
|
|
|
-scheme "UIExplorer" \
|
|
|
|
-sdk "iphonesimulator" \
|
|
|
|
-destination "platform=iOS Simulator,name=iPhone 5s,OS=10.1" \
|
|
|
|
build test
|
2017-03-08 19:33:35 +00:00
|
|
|
|
2017-03-16 22:18:20 +00:00
|
|
|
else
|
|
|
|
|
|
|
|
# Only build for iOS (check there are no missing files in the Xcode project)
|
|
|
|
xcodebuild \
|
|
|
|
-project "Examples/UIExplorer/UIExplorer.xcodeproj" \
|
|
|
|
-scheme "UIExplorer" \
|
|
|
|
-sdk "iphonesimulator" \
|
|
|
|
build
|
|
|
|
|
|
|
|
fi
|