mirror of
https://github.com/status-im/react-native.git
synced 2025-01-10 17:45:59 +00:00
03d57f2180
Summary: It got broken by https://github.com/facebook/react-native/pull/13173. When the test scripts are run without the "test" argument, we only want to compile the code, not run the packager and integration tests. On Travis we pass the "test" argument so we'll still run the packager and integration tests: https://github.com/facebook/react-native/blob/master/.travis.yml Reviewed By: gfosco Differential Revision: D4905912 fbshipit-source-id: e118e6e4f4a818fa06e89d417574e839c4192c1b
79 lines
2.6 KiB
Bash
Executable File
79 lines
2.6 KiB
Bash
Executable File
#!/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 UIExplorer.
|
|
# If the script is called with a single argument "test", we'll
|
|
# also run the UIExplorer 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
|
|
|
|
# If first argument is "test", actually start the packager and run tests.
|
|
# 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"
|
|
# Start the WebSocket test server
|
|
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
|
|
|
|
# Run tests
|
|
# 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 $SCHEME \
|
|
-sdk $SDK \
|
|
-destination "$DESTINATION" \
|
|
build test
|
|
|
|
else
|
|
|
|
# Don't run tests. No need to pass -destination to xcodebuild.
|
|
# 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 $SCHEME \
|
|
-sdk $SDK \
|
|
build
|
|
|
|
fi
|