Internal fixes for the iOS Explorer test script

Summary:
Some changes are required to this scripts in order to successfully run it on Sandcastle:

- the packager needs to be started before the test, doing this only when not running in Travis
- no xcpretty available, piping to anything else (e.g. `cat`) fails
Closes https://github.com/facebook/react-native/pull/8127

Differential Revision: D3437268

Pulled By: avaly

fbshipit-source-id: a0a52f08b31f50b88f5d0fd4d9d6c827df179d71
This commit is contained in:
Valentin Agachi 2016-06-15 08:52:58 -07:00 committed by Facebook Github Bot 3
parent 1fcd73f384
commit 4fe7a25d01

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
set -e set -ex
SCRIPTS=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) SCRIPTS=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
ROOT=$(dirname $SCRIPTS) ROOT=$(dirname $SCRIPTS)
@ -16,9 +16,19 @@ function cleanup {
WATCHMAN_LOGS=/usr/local/Cellar/watchman/3.1/var/run/watchman/$USER.log WATCHMAN_LOGS=/usr/local/Cellar/watchman/3.1/var/run/watchman/$USER.log
[ -f $WATCHMAN_LOGS ] && cat $WATCHMAN_LOGS [ -f $WATCHMAN_LOGS ] && cat $WATCHMAN_LOGS
fi fi
[ $SERVER_PID ] && kill -9 $SERVER_PID
} }
trap cleanup EXIT trap cleanup EXIT
if [ -z "$TRAVIS" ]; then
# Run the packager process directly
node ./local-cli/cli.js start &
SERVER_PID=$!
fi
XCODE_PROJECT="Examples/UIExplorer/UIExplorer.xcodeproj"
XCODE_SCHEME="UIExplorer"
XCODE_SDK="iphonesimulator"
if [ -z "$XCODE_DESTINATION" ]; then if [ -z "$XCODE_DESTINATION" ]; then
XCODE_DESTINATION="platform=iOS Simulator,name=iPhone 5,OS=9.3" XCODE_DESTINATION="platform=iOS Simulator,name=iPhone 5,OS=9.3"
fi fi
@ -27,17 +37,22 @@ fi
set +e set +e
OUTPUT_TOOL=$(which xcpretty) OUTPUT_TOOL=$(which xcpretty)
set -e set -e
if [ -z "$OUTPUT_TOOL" ]; then
OUTPUT_TOOL="sed"
fi
# TODO: We use xcodebuild because xctool would stall when collecting info about # 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 # the tests before running them. Switch back when this issue with xctool has
# been resolved. # been resolved.
xcodebuild \ if [ -z "$OUTPUT_TOOL" ]; then
-project Examples/UIExplorer/UIExplorer.xcodeproj \ xcodebuild \
-scheme UIExplorer \ -project $XCODE_PROJECT \
-sdk iphonesimulator \ -scheme $XCODE_SCHEME \
-destination "$XCODE_DESTINATION" \ -sdk $XCODE_SDK \
test \ -destination "$XCODE_DESTINATION" \
| $OUTPUT_TOOL && exit ${PIPESTATUS[0]} test
else
xcodebuild \
-project $XCODE_PROJECT \
-scheme $XCODE_SCHEME \
-sdk $XCODE_SDK \
-destination "$XCODE_DESTINATION" \
test | $OUTPUT_TOOL && exit ${PIPESTATUS[0]}
fi