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
This commit is contained in:
dlowder-salesforce 2017-03-06 14:10:07 -08:00 committed by Facebook Github Bot
parent 4e437c1232
commit 4c79df9970
4 changed files with 104 additions and 69 deletions

View File

@ -1,6 +1,6 @@
language: objective-c
osx_image: xcode8
osx_image: xcode8.2
install:
- mkdir -p /Users/travis/build/facebook/.nvm
@ -18,6 +18,7 @@ install:
script:
- if [[ "$TEST_TYPE" = objc-ios ]]; then travis_retry travis_wait ./scripts/objc-test-ios.sh; fi
- if [[ "$TEST_TYPE" = objc-tvos ]]; then travis_retry travis_wait ./scripts/objc-test-tvos.sh; fi
- if [[ "$TEST_TYPE" = e2e-objc ]]; then node ./scripts/run-ci-e2e-tests.js --ios --js --retries 3; fi
- if [[ ( "$TEST_TYPE" = podspecs ) && ( "$TRAVIS_PULL_REQUEST" = "false" ) ]]; then gem install cocoapods && ./scripts/process-podspecs.sh; fi
@ -30,6 +31,7 @@ env:
- TEST_TYPE=objc-ios
- TEST_TYPE=podspecs
- TEST_TYPE=e2e-objc
- TEST_TYPE=objc-tvos
branches:
only:
@ -40,6 +42,7 @@ notifications:
email:
recipients:
- mkonicek@fb.com
- douglowder@mac.com # Doug Lowder built and maintains Apple TV specific code and wants to be notified about tvOS failures.
- eloy@artsy.net # Eloy Durán maintains the podspecs test and wants to be notified about failures.
on_failure: change
on_success: change

View File

@ -6,11 +6,45 @@ ROOT=$(dirname $SCRIPTS)
cd $ROOT
XCODE_PROJECT="Examples/UIExplorer/UIExplorer.xcodeproj"
XCODE_SCHEME="UIExplorer"
XCODE_SDK="iphonesimulator"
if [ -z ${XCODE_DESTINATION+x} ]; then
XCODE_DESTINATION="platform=iOS Simulator,name=iPhone 5s,OS=10.0"
fi
# Create cleanup handler
function cleanup {
EXIT_CODE=$?
set +e
. ./scripts/objc-test.sh
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
# 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
# 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

View File

@ -1,5 +1,4 @@
#!/bin/bash
set -ex
SCRIPTS=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
@ -7,11 +6,63 @@ ROOT=$(dirname $SCRIPTS)
cd $ROOT
XCODE_PROJECT="Examples/UIExplorer/UIExplorer.xcodeproj"
XCODE_SCHEME="UIExplorer-tvOS"
XCODE_SDK="appletvsimulator"
if [ -z ${XCODE_DESTINATION+x} ]; then
XCODE_DESTINATION="platform=tvOS Simulator,name=Apple TV 1080p,OS=10.0"
fi
# Create cleanup handler
function cleanup {
EXIT_CODE=$?
set +e
. ./scripts/objc-test.sh
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

View File

@ -1,53 +0,0 @@
#!/bin/bash
# This script contains common code to be run from scripts/objc-test-ios.sh or scripts/objc-test-tvos.sh
# Start the packager and preload the UIExplorerApp bundle for better performance in integration tests
open "./packager/launchPackager.command" || echo "Can't start packager automatically"
open "./IntegrationTests/launchWebSocketServer.command" || echo "Can't start web socket server automatically"
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
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 [ -z "$XCODE_BUILD_STEPS" ]; then
XCODE_BUILD_STEPS="build test"
fi
# 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.
if [ -n "$XCODE_DESTINATION" ]; then
xcodebuild \
-project $XCODE_PROJECT \
-scheme $XCODE_SCHEME \
-sdk $XCODE_SDK \
-destination "$XCODE_DESTINATION" \
$XCODE_BUILD_STEPS
else
xcodebuild \
-project $XCODE_PROJECT \
-scheme $XCODE_SCHEME \
-sdk $XCODE_SDK \
$XCODE_BUILD_STEPS
fi