2015-12-17 20:42:02 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2015-12-16 02:02:20 +00:00
|
|
|
set -o pipefail
|
|
|
|
set -e
|
|
|
|
|
2016-01-22 21:32:56 +00:00
|
|
|
TARGET=$1
|
|
|
|
CONFIGURATION=${2:-"Debug"}
|
|
|
|
|
2016-01-22 21:30:16 +00:00
|
|
|
if [ "$TARGET" != "react-tests-android" ]; then
|
|
|
|
while pgrep -q Simulator; do
|
2015-12-16 02:02:20 +00:00
|
|
|
# Kill all the current simulator processes as they may be from a
|
|
|
|
# different Xcode version
|
2016-01-22 21:30:16 +00:00
|
|
|
pkill Simulator 2>/dev/null || true
|
2015-12-16 02:02:20 +00:00
|
|
|
# CoreSimulatorService doesn't exit when sent SIGTERM
|
2016-01-22 21:30:16 +00:00
|
|
|
pkill -9 Simulator 2>/dev/null || true
|
|
|
|
done
|
|
|
|
DESTINATION="-destination id=$(xcrun simctl list devices | grep -v unavailable | grep -m 1 -o '[0-9A-F\-]\{36\}')"
|
|
|
|
fi
|
2015-12-16 02:02:20 +00:00
|
|
|
|
2016-01-22 22:48:40 +00:00
|
|
|
PACKAGER_OUT="packager_out.txt"
|
2015-12-17 18:56:08 +00:00
|
|
|
function start_packager()
|
|
|
|
{
|
2015-12-17 20:42:02 +00:00
|
|
|
rm -f $PACKAGER_OUT
|
2016-01-22 20:15:38 +00:00
|
|
|
sh ./node_modules/react-native/packager/packager.sh | tee $PACKAGER_OUT &
|
2015-12-17 18:56:08 +00:00
|
|
|
while :;
|
|
|
|
do
|
2016-01-22 21:26:37 +00:00
|
|
|
if grep -Fxq "React packager ready." $PACKAGER_OUT
|
2015-12-17 18:56:08 +00:00
|
|
|
then
|
|
|
|
break
|
|
|
|
else
|
|
|
|
echo "Waiting for packager."
|
2015-12-17 20:42:02 +00:00
|
|
|
sleep 2
|
2016-01-22 23:23:27 +00:00
|
|
|
fi
|
2015-12-17 18:56:08 +00:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2016-01-22 23:03:00 +00:00
|
|
|
# kill old packagers
|
|
|
|
pkill node || true
|
2015-12-16 02:02:20 +00:00
|
|
|
|
|
|
|
if [ "$TARGET" = "realmjs" ]; then
|
2016-01-22 23:23:27 +00:00
|
|
|
xcodebuild -scheme RealmJS -configuration "$CONFIGURATION" -sdk iphonesimulator $DESTINATION build test
|
2015-12-16 02:02:20 +00:00
|
|
|
elif [ "$TARGET" = "react-tests" ]; then
|
|
|
|
pushd tests/react-test-app
|
2015-12-18 23:11:23 +00:00
|
|
|
|
2015-12-18 23:54:02 +00:00
|
|
|
if [ -d ~/Applications/Google\ Chrome.app ]; then
|
|
|
|
open ~/Applications/Google\ Chrome.app
|
|
|
|
fi
|
2015-12-18 23:11:23 +00:00
|
|
|
|
2015-12-16 02:18:18 +00:00
|
|
|
if [ -f ../../target=node_modules/react_tests_node_modules.zip ]; then
|
2015-12-17 19:55:29 +00:00
|
|
|
unzip -q ../../target=node_modules/react_tests_node_modules.zip
|
2015-12-16 02:18:18 +00:00
|
|
|
fi
|
2015-12-17 02:14:14 +00:00
|
|
|
npm update react-native
|
2015-12-17 18:56:08 +00:00
|
|
|
start_packager
|
2015-12-16 02:02:20 +00:00
|
|
|
popd
|
2016-01-22 23:23:27 +00:00
|
|
|
|
2015-12-16 02:02:20 +00:00
|
|
|
xcodebuild -scheme RealmReact -configuration "$CONFIGURATION" -sdk iphonesimulator $DESTINATION build test
|
|
|
|
elif [ "$TARGET" = "react-example" ]; then
|
|
|
|
pushd examples/ReactExample
|
2015-12-16 02:18:18 +00:00
|
|
|
if [ -f ../../target=node_modules/react_example_node_modules.zip ]; then
|
2015-12-17 19:55:29 +00:00
|
|
|
unzip -q ../../target=node_modules/react_example_node_modules.zip
|
2015-12-16 02:18:18 +00:00
|
|
|
fi
|
2015-12-17 02:14:14 +00:00
|
|
|
npm update react-native
|
2015-12-17 18:56:08 +00:00
|
|
|
start_packager
|
|
|
|
|
2016-01-22 23:27:17 +00:00
|
|
|
pushd ios
|
2015-12-16 02:02:20 +00:00
|
|
|
xcodebuild -scheme ReactExample -configuration "$CONFIGURATION" -sdk iphonesimulator build $DESTINATION
|
|
|
|
popd
|
2016-01-22 20:15:38 +00:00
|
|
|
elif [ "$TARGET" = "react-tests-android" ]; then
|
2016-01-22 23:42:28 +00:00
|
|
|
# Copy patched version of FB
|
2016-01-22 23:50:40 +00:00
|
|
|
rm -Rf ~/.m2/repository/com/facebook/react/react-native/
|
2016-01-22 23:42:28 +00:00
|
|
|
mkdir -p ~/.m2/repository/com/facebook/react/react-native/
|
|
|
|
tar xvf ./patched_bin/0.18.0-patched.tar.gz -C ~/.m2/repository/com/facebook/react/react-native/
|
2016-01-22 23:54:17 +00:00
|
|
|
# # update sdk tool
|
|
|
|
# expect -c '
|
|
|
|
# set timeout -1;
|
|
|
|
# spawn /opt/android-sdk-linux/tools/android update sdk -u -a -t "build-tools-23.0.1";
|
|
|
|
# expect {
|
|
|
|
# "Do you accept the license" { exp_send "y\r" ; exp_continue }
|
|
|
|
# eof
|
|
|
|
# }
|
|
|
|
# '
|
2016-01-22 23:23:27 +00:00
|
|
|
|
2016-01-22 20:15:38 +00:00
|
|
|
pushd react-native/android
|
|
|
|
./gradlew installarchives
|
|
|
|
popd
|
|
|
|
|
|
|
|
pushd tests/react-test-app
|
|
|
|
|
|
|
|
if [ -d ~/Applications/Google\ Chrome.app ]; then
|
|
|
|
open ~/Applications/Google\ Chrome.app
|
|
|
|
fi
|
|
|
|
|
|
|
|
npm install
|
|
|
|
start_packager
|
|
|
|
|
|
|
|
sh run-android.sh
|
2016-01-22 23:23:27 +00:00
|
|
|
|
2016-01-22 20:15:38 +00:00
|
|
|
LOGCAT_OUT="logcat_out.txt"
|
|
|
|
rm -f $LOGCAT_OUT
|
2016-01-22 23:03:00 +00:00
|
|
|
|
2016-01-22 20:19:47 +00:00
|
|
|
adb logcat -c
|
2016-01-22 20:15:38 +00:00
|
|
|
adb logcat | tee $LOGCAT_OUT &
|
|
|
|
while :;
|
|
|
|
do
|
2016-01-22 21:26:37 +00:00
|
|
|
if grep -q "FILE WRITTEN!!" $LOGCAT_OUT
|
2016-01-22 20:15:38 +00:00
|
|
|
then
|
|
|
|
break
|
|
|
|
else
|
|
|
|
echo "Waiting for tests."
|
|
|
|
sleep 2
|
2016-01-22 23:23:27 +00:00
|
|
|
fi
|
|
|
|
done
|
2016-01-22 20:15:38 +00:00
|
|
|
|
2016-01-22 23:03:00 +00:00
|
|
|
adb pull /data/data/com.demo/files/tests.xml . || true
|
2015-12-17 02:14:14 +00:00
|
|
|
else
|
|
|
|
echo "Invalid target '${TARGET}'"
|
2015-12-16 02:02:20 +00:00
|
|
|
fi
|
|
|
|
|
2016-01-22 23:03:00 +00:00
|
|
|
# kill all children
|
2016-01-22 23:07:17 +00:00
|
|
|
pkill -P $$ || true
|
2016-01-22 23:03:00 +00:00
|
|
|
pkill node || true
|
|
|
|
rm -f $PACKAGER_OUT
|
|
|
|
rm -f $LOGCAT_OUT
|