react-native/scripts/objc-test-tvos.sh
dlowder-salesforce 4c79df9970 Clean up objc-test-ios.sh, include tvOS build check
Summary:
**Motivation**: Having full tests for both iOS and tvOS is hard on Travis, and it's probably ok to not run full tests on tvOS.  However, we should make sure that tvOS at least builds and doesn't have missing files.

Also fixed a warning import.
Closes https://github.com/facebook/react-native/pull/12642

Differential Revision: D4661571

Pulled By: mkonicek

fbshipit-source-id: 45932113951c01e35d6e8ce91af2522cb135efe8
2017-03-06 14:15:30 -08:00

69 lines
2.3 KiB
Bash
Executable File

#!/bin/bash
set -ex
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
# If first argument is "test", actually start the packager and run tests as in the iOS script
# Otherwise, just build UIExplorer for tvOS and exit
if [ "$1" = "test" ];
then
# Start the packager
open "./packager/launchPackager.command" || echo "Can't start packager automatically"
open "./IntegrationTests/launchWebSocketServer.command" || echo "Can't start web socket server automatically"
# Preload the UIExplorerApp bundle for better performance in integration tests
sleep 20
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
# Build and test for tvOS
# 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-tvOS" \
-sdk "appletvsimulator" \
-destination "platform=tvOS Simulator,name=Apple TV 1080p,OS=10.1" \
build test
else
# Build only (no test) for tvOS, to make sure there are no missing files
xcodebuild \
-project "Examples/UIExplorer/UIExplorer.xcodeproj" \
-scheme "UIExplorer-tvOS" \
-sdk "appletvsimulator" \
-destination "platform=tvOS Simulator,name=Apple TV 1080p,OS=10.1" \
build
fi