2015-12-17 20:42:02 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2015-12-16 02:02:20 +00:00
|
|
|
set -o pipefail
|
|
|
|
set -e
|
|
|
|
|
2016-08-19 17:06:45 +00:00
|
|
|
export TEST_SCRIPT=1
|
|
|
|
export NPM_CONFIG_PROGRESS=false
|
|
|
|
|
2016-12-22 18:02:15 +00:00
|
|
|
TARGET=$1
|
|
|
|
CONFIGURATION=${2:-Release}
|
|
|
|
|
2017-09-18 20:23:27 +00:00
|
|
|
if echo "$CONFIGURATION" | grep -i "^Debug$" > /dev/null ; then
|
2017-03-16 11:15:20 +00:00
|
|
|
CONFIGURATION="Debug"
|
|
|
|
fi
|
|
|
|
|
2016-12-22 18:02:15 +00:00
|
|
|
IOS_SIM_DEVICE=${IOS_SIM_DEVICE:-} # use preferentially, otherwise will be set and re-exported
|
|
|
|
|
2016-01-27 00:12:26 +00:00
|
|
|
PATH="/opt/android-sdk-linux/platform-tools:$PATH"
|
|
|
|
SRCROOT=$(cd "$(dirname "$0")/.." && pwd)
|
2017-01-02 12:35:45 +00:00
|
|
|
XCPRETTY=$(which xcpretty || true)
|
2016-12-22 18:02:15 +00:00
|
|
|
CI_RUN=false
|
|
|
|
if [ -n "${JENKINS_HOME}" ]; then
|
|
|
|
CI_RUN=true
|
|
|
|
fi
|
2016-01-22 21:32:56 +00:00
|
|
|
|
2017-12-04 13:56:42 +00:00
|
|
|
SIM_DEVICE_NAME=realm-js-test
|
|
|
|
|
2016-01-27 00:12:26 +00:00
|
|
|
# Start current working directory at the root of the project.
|
|
|
|
cd "$SRCROOT"
|
|
|
|
|
2016-04-19 23:57:52 +00:00
|
|
|
# Add node_modules to PATH just in case we weren't called from `npm test`
|
|
|
|
PATH="$PWD/node_modules/.bin:$PATH"
|
|
|
|
|
2016-03-02 23:47:51 +00:00
|
|
|
if [[ $TARGET = *-android ]]; then
|
|
|
|
# Inform the prepublish script to build Android modules.
|
|
|
|
export REALM_BUILD_ANDROID=1
|
2016-01-22 21:30:16 +00:00
|
|
|
fi
|
2015-12-16 02:02:20 +00:00
|
|
|
|
2016-11-09 00:47:20 +00:00
|
|
|
SERVER_PID=0
|
2016-01-27 00:12:26 +00:00
|
|
|
PACKAGER_OUT="$SRCROOT/packager_out.txt"
|
|
|
|
LOGCAT_OUT="$SRCROOT/logcat_out.txt"
|
|
|
|
|
2017-10-30 19:57:45 +00:00
|
|
|
die() {
|
|
|
|
echo "$@" >&2
|
|
|
|
exit 1
|
|
|
|
}
|
2016-11-09 00:47:20 +00:00
|
|
|
|
|
|
|
download_server() {
|
2017-09-18 22:07:28 +00:00
|
|
|
echo "test.sh: downloading ROS"
|
2017-07-12 16:50:37 +00:00
|
|
|
./scripts/download-object-server.sh
|
2016-11-09 00:47:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
start_server() {
|
2017-09-18 22:07:28 +00:00
|
|
|
echo "test.sh: starting ROS"
|
2017-09-08 16:56:40 +00:00
|
|
|
#disabled ROS logging
|
2017-09-18 22:07:28 +00:00
|
|
|
# sh ./object-server-for-testing/start-object-server.command &> /dev/null &
|
2017-09-08 16:56:40 +00:00
|
|
|
|
|
|
|
#enabled ROS logging
|
|
|
|
#sh ./object-server-for-testing/start-object-server.command &
|
2017-11-14 09:43:02 +00:00
|
|
|
export ROS_SKIP_PROMPTS=true && ./node_modules/.bin/ros start --data realm-object-server-data &
|
2016-11-09 00:47:20 +00:00
|
|
|
SERVER_PID=$!
|
2017-09-18 22:07:28 +00:00
|
|
|
echo ROS PID: ${SERVER_PID}
|
2016-11-09 00:47:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stop_server() {
|
2017-09-30 07:55:14 +00:00
|
|
|
echo stopping server
|
2017-01-02 12:35:45 +00:00
|
|
|
if [[ ${SERVER_PID} -gt 0 ]] ; then
|
2017-09-18 22:07:28 +00:00
|
|
|
echo server is running. killing it
|
2017-12-14 10:17:49 +00:00
|
|
|
kill -9 ${SERVER_PID} >/dev/null 2>&1 || true
|
2016-11-09 00:47:20 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2016-12-22 18:02:15 +00:00
|
|
|
startedSimulator=false
|
|
|
|
log_temp=
|
|
|
|
test_temp_dir=
|
2016-01-27 00:12:26 +00:00
|
|
|
cleanup() {
|
2016-11-09 00:47:20 +00:00
|
|
|
# Kill started object server
|
2016-12-22 18:02:15 +00:00
|
|
|
stop_server || true
|
2017-01-02 12:35:45 +00:00
|
|
|
|
2017-12-06 12:43:02 +00:00
|
|
|
echo "shutting down running simulators"
|
|
|
|
shutdown_ios_simulator >/dev/null 2>&1
|
2018-01-26 16:21:09 +00:00
|
|
|
|
2016-12-22 18:02:15 +00:00
|
|
|
# Quit Simulator.app to give it a chance to go down gracefully
|
|
|
|
if $startedSimulator; then
|
|
|
|
osascript -e 'tell app "Simulator" to quit without saving' || true
|
|
|
|
sleep 0.25 # otherwise the pkill following will get it too early
|
|
|
|
fi
|
2017-01-02 12:35:45 +00:00
|
|
|
|
2016-12-22 18:02:15 +00:00
|
|
|
# Kill all child processes.
|
|
|
|
pkill -9 -P $$ || true
|
2016-11-09 00:47:20 +00:00
|
|
|
|
|
|
|
# Kill react native packager
|
2017-01-04 14:07:25 +00:00
|
|
|
pkill -x node || true
|
2016-01-27 00:12:26 +00:00
|
|
|
rm -f "$PACKAGER_OUT" "$LOGCAT_OUT"
|
2017-01-02 12:35:45 +00:00
|
|
|
|
2016-12-22 18:02:15 +00:00
|
|
|
# Cleanup temp files
|
|
|
|
if [ -n "$log_temp" ] && [ -e "$log_temp" ]; then
|
|
|
|
rm "$log_temp" || true
|
|
|
|
fi
|
|
|
|
if [ -n "$test_temp_dir" ] && [ -e "$test_temp_dir" ]; then
|
|
|
|
rm -rf "$test_temp_dir" || true
|
|
|
|
fi
|
2016-01-27 00:12:26 +00:00
|
|
|
}
|
|
|
|
|
2018-01-26 16:21:09 +00:00
|
|
|
open_chrome() {
|
2017-12-04 13:56:42 +00:00
|
|
|
if [ $CONFIGURATION == 'Release' ]; then
|
2017-12-14 10:17:49 +00:00
|
|
|
return;
|
2017-12-04 13:56:42 +00:00
|
|
|
fi
|
2018-01-26 16:21:09 +00:00
|
|
|
|
2016-01-27 00:12:26 +00:00
|
|
|
local dir
|
|
|
|
for dir in "$HOME/Applications" "/Applications"; do
|
|
|
|
if [ -d "$dir/Google Chrome.app" ]; then
|
|
|
|
open "$dir/Google Chrome.app"
|
|
|
|
break
|
|
|
|
fi
|
2015-12-17 18:56:08 +00:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2016-01-27 00:12:26 +00:00
|
|
|
start_packager() {
|
2016-03-16 20:30:06 +00:00
|
|
|
watchman watch-del-all || true
|
2017-11-15 10:59:13 +00:00
|
|
|
./node_modules/react-native/scripts/packager.sh | tee "$PACKAGER_OUT" &
|
2016-01-27 00:12:26 +00:00
|
|
|
|
|
|
|
while :; do
|
2017-11-15 10:59:13 +00:00
|
|
|
if grep -Fxq "Metro Bundler ready." "$PACKAGER_OUT"; then
|
2016-01-27 00:12:26 +00:00
|
|
|
break
|
|
|
|
else
|
|
|
|
echo "Waiting for packager."
|
|
|
|
sleep 2
|
|
|
|
fi
|
|
|
|
done
|
2016-01-26 20:23:26 +00:00
|
|
|
}
|
|
|
|
|
2016-05-13 23:30:57 +00:00
|
|
|
xctest() {
|
2016-12-22 18:02:15 +00:00
|
|
|
setup_ios_simulator
|
2017-01-02 12:35:45 +00:00
|
|
|
|
2016-12-22 18:02:15 +00:00
|
|
|
# - Run the build and test
|
2017-12-04 13:56:42 +00:00
|
|
|
echo "Building application"
|
|
|
|
xcrun xcodebuild -scheme "$1" -configuration "$CONFIGURATION" -sdk iphonesimulator -destination id="${IOS_SIM_DEVICE_ID}" -derivedDataPath ./build build || {
|
2017-09-19 05:32:41 +00:00
|
|
|
EXITCODE=$?
|
|
|
|
echo "*** Failure (exit code $EXITCODE). ***"
|
|
|
|
exit $EXITCODE
|
|
|
|
}
|
2018-01-26 16:21:09 +00:00
|
|
|
|
2017-12-04 13:56:42 +00:00
|
|
|
echo "Installing application on ${SIM_DEVICE_NAME}"
|
2017-12-06 12:43:02 +00:00
|
|
|
echo "Application Path" $(pwd)/build/Build/Products/$CONFIGURATION-iphonesimulator/$1.app
|
|
|
|
xcrun simctl install ${SIM_DEVICE_NAME} $(pwd)/build/Build/Products/$CONFIGURATION-iphonesimulator/$1.app
|
2018-01-26 16:21:09 +00:00
|
|
|
|
|
|
|
|
2017-12-06 12:43:02 +00:00
|
|
|
echo "Launching application. (output is in $(pwd)/build/out.txt)"
|
|
|
|
xcrun simctl launch --console ${SIM_DEVICE_NAME} io.realm.$1 | tee $(pwd)/build/out.txt
|
2017-12-04 13:56:42 +00:00
|
|
|
|
|
|
|
echo "Shuttting down ${SIM_DEVICE_NAME} simulator. (device is not deleted. you can use it to debug the app)"
|
2017-12-06 12:43:02 +00:00
|
|
|
shutdown_ios_simulator
|
2017-12-04 13:56:42 +00:00
|
|
|
|
2017-12-14 10:17:49 +00:00
|
|
|
check_test_results $1
|
|
|
|
}
|
|
|
|
|
|
|
|
check_test_results() {
|
2017-12-04 13:56:42 +00:00
|
|
|
echo "Checking tests results"
|
2017-12-06 12:43:02 +00:00
|
|
|
if grep -q "REALM_FAILING_TESTS" $(pwd)/build/out.txt; then
|
2017-12-04 13:56:42 +00:00
|
|
|
echo "*** REALM JS TESTS FAILED. See tests results above ***"
|
|
|
|
exit 20
|
2016-08-19 17:06:45 +00:00
|
|
|
else
|
2017-12-06 12:43:02 +00:00
|
|
|
echo "*** $1 SUCCESS ***"
|
2016-12-22 18:02:15 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2018-01-26 16:21:09 +00:00
|
|
|
setup_ios_simulator() {
|
2017-12-06 12:43:02 +00:00
|
|
|
#try deleting old simulator with same name.
|
|
|
|
echo "Preparing to create a new simulator"
|
|
|
|
delete_ios_simulator >/dev/null 2>&1
|
2017-01-02 12:35:45 +00:00
|
|
|
|
2017-12-04 13:56:42 +00:00
|
|
|
#parse devices
|
2017-12-14 10:17:49 +00:00
|
|
|
IOS_RUNTIME=$(xcrun simctl list runtimes | grep -m1 -o 'com.apple.CoreSimulator.SimRuntime.iOS.*' | sed 's/[()]//g')
|
2017-12-04 13:56:42 +00:00
|
|
|
echo using iOS Runtime ${IOS_RUNTIME} to create new simulator ${SIM_DEVICE_NAME}
|
2017-01-02 12:35:45 +00:00
|
|
|
|
2017-12-04 13:56:42 +00:00
|
|
|
#create new test simulator
|
|
|
|
IOS_SIM_DEVICE_ID=$(xcrun simctl create ${SIM_DEVICE_NAME} com.apple.CoreSimulator.SimDeviceType.iPhone-SE ${IOS_RUNTIME})
|
|
|
|
#boot new test simulator
|
|
|
|
xcrun simctl boot ${SIM_DEVICE_NAME}
|
|
|
|
}
|
2017-01-02 12:35:45 +00:00
|
|
|
|
2018-01-26 16:21:09 +00:00
|
|
|
shutdown_ios_simulator() {
|
2017-12-04 13:56:42 +00:00
|
|
|
#shutdown test simulator
|
|
|
|
xcrun simctl shutdown ${SIM_DEVICE_NAME} || true
|
2017-12-06 12:43:02 +00:00
|
|
|
}
|
|
|
|
|
2018-01-26 16:21:09 +00:00
|
|
|
delete_ios_simulator() {
|
2017-12-06 12:43:02 +00:00
|
|
|
shutdown_ios_simulator
|
|
|
|
|
2017-12-04 13:56:42 +00:00
|
|
|
#delete test simulator
|
|
|
|
xcrun simctl delete ${SIM_DEVICE_NAME} || true
|
2016-01-27 00:12:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Cleanup now and also cleanup when this script exits.
|
2017-12-06 12:43:02 +00:00
|
|
|
cleanup >/dev/null 2>&1
|
2016-01-27 00:12:26 +00:00
|
|
|
trap cleanup EXIT
|
2015-12-16 02:02:20 +00:00
|
|
|
|
2016-02-19 10:53:10 +00:00
|
|
|
# Use a consistent version of Node if possible.
|
2017-09-18 23:19:33 +00:00
|
|
|
if [[ -z "$(command -v nvm)" ]]; then
|
2017-09-19 04:08:19 +00:00
|
|
|
set +e
|
2017-09-18 23:19:33 +00:00
|
|
|
if [ -f "$NVM_DIR/nvm.sh" ]; then
|
2017-09-19 02:16:28 +00:00
|
|
|
. "$NVM_DIR/nvm.sh" '' || true
|
2017-09-18 23:19:33 +00:00
|
|
|
elif [ -x "$(command -v brew)" ] && [ -f "$(brew --prefix nvm)/nvm.sh" ]; then
|
|
|
|
# we must be on mac and nvm was installed with brew
|
|
|
|
# TODO: change the mac slaves to use manual nvm installation
|
2017-09-19 02:16:28 +00:00
|
|
|
. "$(brew --prefix nvm)/nvm.sh" '' || true
|
2017-09-18 23:19:33 +00:00
|
|
|
elif [ -f "$HOME/.nvm/nvm.sh" ]; then
|
2017-09-19 02:16:28 +00:00
|
|
|
. ~/.nvm/nvm.sh ''
|
2017-09-18 23:19:33 +00:00
|
|
|
fi
|
2017-09-19 04:08:19 +00:00
|
|
|
set -e
|
2017-09-18 20:23:27 +00:00
|
|
|
fi
|
|
|
|
if [[ "$(command -v nvm)" ]]; then
|
2017-09-25 16:40:56 +00:00
|
|
|
nvm install 7.10.0
|
2016-02-19 10:53:10 +00:00
|
|
|
fi
|
|
|
|
|
2016-11-11 07:11:31 +00:00
|
|
|
# Remove cached packages
|
|
|
|
rm -rf ~/.yarn-cache/npm-realm-*
|
|
|
|
|
2016-01-27 00:12:26 +00:00
|
|
|
case "$TARGET" in
|
2017-08-14 08:30:03 +00:00
|
|
|
"check-environment")
|
|
|
|
npm run check-environment
|
|
|
|
;;
|
2016-03-02 23:16:22 +00:00
|
|
|
"eslint")
|
2017-03-27 12:38:46 +00:00
|
|
|
[[ $CONFIGURATION == 'Debug' ]] && exit 0
|
2017-03-22 12:01:09 +00:00
|
|
|
npm run eslint
|
2016-03-02 23:16:22 +00:00
|
|
|
;;
|
2016-11-17 15:55:02 +00:00
|
|
|
"eslint-ci")
|
|
|
|
[[ $CONFIGURATION == 'Debug' ]] && exit 0
|
|
|
|
npm install
|
|
|
|
./node_modules/.bin/eslint -f checkstyle . > eslint.xml || true
|
|
|
|
;;
|
2017-02-06 10:33:14 +00:00
|
|
|
"license-check")
|
2017-03-27 12:38:46 +00:00
|
|
|
[[ $CONFIGURATION == 'Debug' ]] && exit 0
|
2017-03-22 12:01:09 +00:00
|
|
|
npm run license-check
|
2017-02-06 10:33:14 +00:00
|
|
|
;;
|
2016-02-12 10:47:08 +00:00
|
|
|
"jsdoc")
|
2016-03-17 00:49:20 +00:00
|
|
|
[[ $CONFIGURATION == 'Debug' ]] && exit 0
|
2016-02-12 10:47:08 +00:00
|
|
|
npm run jsdoc
|
|
|
|
;;
|
2016-01-27 00:12:26 +00:00
|
|
|
"react-tests")
|
2017-08-14 08:30:03 +00:00
|
|
|
npm run check-environment
|
2017-01-31 13:07:29 +00:00
|
|
|
download_server
|
|
|
|
start_server
|
2015-12-16 02:02:20 +00:00
|
|
|
pushd tests/react-test-app
|
2016-11-11 07:55:26 +00:00
|
|
|
npm install
|
2016-01-27 00:12:26 +00:00
|
|
|
open_chrome
|
2015-12-17 18:56:08 +00:00
|
|
|
start_packager
|
2016-01-22 23:23:27 +00:00
|
|
|
|
2016-03-23 20:20:05 +00:00
|
|
|
pushd ios
|
2017-12-06 12:43:02 +00:00
|
|
|
xctest ReactTests
|
2017-01-31 13:07:29 +00:00
|
|
|
stop_server
|
2016-01-27 00:12:26 +00:00
|
|
|
;;
|
|
|
|
"react-example")
|
2017-08-14 08:30:03 +00:00
|
|
|
npm run check-environment
|
2015-12-16 02:02:20 +00:00
|
|
|
pushd examples/ReactExample
|
2016-01-27 00:12:26 +00:00
|
|
|
|
2016-02-19 10:28:59 +00:00
|
|
|
npm install
|
2016-02-16 08:37:10 +00:00
|
|
|
open_chrome
|
2015-12-17 18:56:08 +00:00
|
|
|
start_packager
|
|
|
|
|
2017-12-13 16:36:10 +00:00
|
|
|
echo "{ \"test\" : true }" > $(pwd)/components/params.json
|
2016-01-22 23:27:17 +00:00
|
|
|
pushd ios
|
2016-12-22 18:02:15 +00:00
|
|
|
xctest ReactExample
|
2017-12-13 16:36:10 +00:00
|
|
|
popd
|
|
|
|
echo "{}" > $(pwd)/components/params.json
|
2016-01-27 00:12:26 +00:00
|
|
|
;;
|
|
|
|
"react-tests-android")
|
2017-08-14 08:30:03 +00:00
|
|
|
npm run check-environment
|
2017-02-02 01:41:27 +00:00
|
|
|
if [ "$(uname)" = 'Darwin' ]; then
|
|
|
|
download_server
|
|
|
|
start_server
|
|
|
|
fi
|
|
|
|
|
2016-03-17 00:49:20 +00:00
|
|
|
[[ $CONFIGURATION == 'Debug' ]] && exit 0
|
2016-11-18 22:00:30 +00:00
|
|
|
XCPRETTY=''
|
2016-02-08 19:16:18 +00:00
|
|
|
|
2017-12-14 10:17:49 +00:00
|
|
|
pushd react-native/android
|
|
|
|
$(pwd)/gradlew publishAndroid
|
|
|
|
popd
|
2016-01-22 20:15:38 +00:00
|
|
|
|
2017-12-14 10:17:49 +00:00
|
|
|
pushd tests/react-test-app
|
2016-01-22 20:15:38 +00:00
|
|
|
npm install
|
2016-01-22 23:23:27 +00:00
|
|
|
|
2016-12-20 19:01:45 +00:00
|
|
|
echo "Resetting logcat"
|
2016-02-02 22:52:15 +00:00
|
|
|
# Despite the docs claiming -c to work, it doesn't, so `-T 1` alleviates that.
|
2017-12-14 10:17:49 +00:00
|
|
|
mkdir -p $(pwd)/build || true
|
2016-01-27 00:12:26 +00:00
|
|
|
adb logcat -c
|
2017-12-14 10:17:49 +00:00
|
|
|
adb logcat -T 1 | tee "$LOGCAT_OUT" | tee $(pwd)/build/out.txt &
|
2016-01-27 00:12:26 +00:00
|
|
|
|
2016-12-20 19:01:45 +00:00
|
|
|
./run-android.sh
|
|
|
|
|
|
|
|
echo "Start listening for Test completion"
|
|
|
|
|
2016-01-27 00:12:26 +00:00
|
|
|
while :; do
|
2017-12-14 10:17:49 +00:00
|
|
|
if grep -q "__REALM_JS_TESTS_COMPLETED__" "$LOGCAT_OUT"; then
|
2016-01-27 00:12:26 +00:00
|
|
|
break
|
|
|
|
else
|
|
|
|
echo "Waiting for tests."
|
|
|
|
sleep 2
|
|
|
|
fi
|
2016-01-22 23:23:27 +00:00
|
|
|
done
|
2016-01-22 20:15:38 +00:00
|
|
|
|
2016-02-02 22:52:15 +00:00
|
|
|
rm -f tests.xml
|
|
|
|
adb pull /sdcard/tests.xml .
|
2016-01-27 00:12:26 +00:00
|
|
|
|
2016-02-02 22:52:15 +00:00
|
|
|
# Stop running child processes before printing results.
|
|
|
|
cleanup
|
2016-01-26 21:10:23 +00:00
|
|
|
echo "********* TESTS COMPLETED *********";
|
2016-01-27 00:12:26 +00:00
|
|
|
echo "********* File location: $(pwd)/tests.xml *********";
|
2016-02-02 22:52:15 +00:00
|
|
|
cat tests.xml
|
2018-01-26 16:21:09 +00:00
|
|
|
|
2017-12-14 10:17:49 +00:00
|
|
|
check_test_results ReactTests
|
2016-01-27 00:12:26 +00:00
|
|
|
;;
|
2016-04-19 21:10:10 +00:00
|
|
|
"node")
|
2017-08-14 08:30:03 +00:00
|
|
|
npm run check-environment
|
2016-11-10 13:42:58 +00:00
|
|
|
if [ "$(uname)" = 'Darwin' ]; then
|
2017-09-18 22:07:28 +00:00
|
|
|
echo "downloading server"
|
2016-11-10 13:42:58 +00:00
|
|
|
download_server
|
2017-09-18 22:07:28 +00:00
|
|
|
echo "starting server"
|
2016-11-10 13:42:58 +00:00
|
|
|
start_server
|
2017-09-30 07:55:14 +00:00
|
|
|
|
2016-11-10 13:42:58 +00:00
|
|
|
npm_tests_cmd="npm run test"
|
2017-07-12 00:11:49 +00:00
|
|
|
npm install --build-from-source=realm --realm_enable_sync
|
2017-09-18 22:07:28 +00:00
|
|
|
|
2016-11-10 13:42:58 +00:00
|
|
|
else
|
2017-03-30 08:24:46 +00:00
|
|
|
npm_tests_cmd="npm run test"
|
2017-07-12 00:11:49 +00:00
|
|
|
npm install --build-from-source=realm
|
2016-11-10 13:42:58 +00:00
|
|
|
fi
|
2016-10-11 20:30:39 +00:00
|
|
|
|
2016-05-13 23:30:57 +00:00
|
|
|
# Change to a temp directory.
|
|
|
|
cd "$(mktemp -q -d -t realm.node.XXXXXX)"
|
2016-12-22 18:02:15 +00:00
|
|
|
test_temp_dir=$PWD # set it to be cleaned at exit
|
2016-04-19 21:10:10 +00:00
|
|
|
|
2016-10-04 22:02:51 +00:00
|
|
|
pushd "$SRCROOT/tests"
|
|
|
|
npm install
|
2017-07-12 16:50:37 +00:00
|
|
|
eval "$npm_tests_cmd"
|
2016-10-04 22:02:51 +00:00
|
|
|
popd
|
2016-11-09 00:47:20 +00:00
|
|
|
stop_server
|
2016-04-19 21:10:10 +00:00
|
|
|
;;
|
2017-08-11 08:30:57 +00:00
|
|
|
"electron")
|
|
|
|
if [ "$(uname)" = 'Darwin' ]; then
|
|
|
|
download_server
|
|
|
|
start_server
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Change to a temp directory - because this is what is done for node - but we pushd right after?
|
|
|
|
cd "$(mktemp -q -d -t realm.electron.XXXXXX)"
|
|
|
|
test_temp_dir=$PWD # set it to be cleaned at exit
|
|
|
|
pushd "$SRCROOT/tests/electron"
|
|
|
|
|
|
|
|
if [ "$(uname)" = 'Darwin' ]; then
|
|
|
|
npm install --build-from-source --realm_enable_sync
|
|
|
|
else
|
|
|
|
npm install --build-from-source
|
|
|
|
fi
|
|
|
|
|
|
|
|
# npm test -- --filter=ListTests
|
|
|
|
# npm test -- --filter=LinkingObjectsTests
|
|
|
|
# npm test -- --filter=ObjectTests
|
|
|
|
# npm test -- --filter=RealmTests
|
|
|
|
# npm test -- --filter=ResultsTests
|
|
|
|
# npm test -- --filter=QueryTests
|
|
|
|
# npm test -- --filter=MigrationTests
|
|
|
|
# npm test -- --filter=EncryptionTests
|
|
|
|
# npm test -- --filter=UserTests
|
|
|
|
# npm test -- --filter=SessionTests
|
|
|
|
# npm test -- --filter=GarbageCollectionTests
|
|
|
|
# npm test -- --filter=AsyncTests
|
|
|
|
|
|
|
|
npm test -- --process=main
|
|
|
|
npm test -- --process=render
|
|
|
|
|
|
|
|
popd
|
|
|
|
|
|
|
|
if [ "$(uname)" = 'Darwin' ]; then
|
|
|
|
stop_server
|
|
|
|
fi
|
|
|
|
;;
|
2016-08-10 13:47:55 +00:00
|
|
|
"test-runners")
|
2017-08-14 08:30:03 +00:00
|
|
|
npm run check-environment
|
2017-03-22 12:01:09 +00:00
|
|
|
npm run test-runners
|
2016-08-10 13:47:55 +00:00
|
|
|
;;
|
2017-08-30 11:09:40 +00:00
|
|
|
"all")
|
|
|
|
# Run all tests that must pass before publishing.
|
|
|
|
for test in eslint license-check react-example react-tests-android react-tests; do
|
|
|
|
for configuration in Debug Release; do
|
|
|
|
echo "RUNNING TEST: $test ($configuration)"
|
|
|
|
echo '----------------------------------------'
|
|
|
|
npm test "$test" "$configuration" || die "Test Failed: $test ($configuration)"
|
|
|
|
echo
|
|
|
|
done
|
|
|
|
done
|
|
|
|
;;
|
2016-03-03 22:58:05 +00:00
|
|
|
"object-store")
|
|
|
|
pushd src/object-store
|
2017-01-02 12:35:45 +00:00
|
|
|
cmake -DCMAKE_BUILD_TYPE="$CONFIGURATION" .
|
2016-03-03 22:58:05 +00:00
|
|
|
make run-tests
|
2016-04-19 21:10:10 +00:00
|
|
|
;;
|
2016-10-04 22:02:51 +00:00
|
|
|
"download-object-server")
|
2017-01-02 12:35:45 +00:00
|
|
|
# shellcheck disable=SC1091
|
2016-10-04 22:02:51 +00:00
|
|
|
. dependencies.list
|
|
|
|
|
|
|
|
object_server_bundle="realm-object-server-bundled_node_darwin-$REALM_OBJECT_SERVER_VERSION.tar.gz"
|
|
|
|
curl -f -L "https://static.realm.io/downloads/object-server/$object_server_bundle" -o "$object_server_bundle"
|
|
|
|
rm -rf tests/sync-bundle
|
|
|
|
mkdir -p tests/sync-bundle
|
|
|
|
tar -C tests/sync-bundle -xf "$object_server_bundle"
|
|
|
|
rm "$object_server_bundle"
|
|
|
|
|
|
|
|
echo -e "enterprise:\n skip_setup: true\n" >> "tests/sync-bundle/object-server/configuration.yml"
|
|
|
|
touch "tests/sync-bundle/object-server/do_not_open_browser"
|
|
|
|
;;
|
2016-01-27 00:12:26 +00:00
|
|
|
*)
|
2015-12-17 02:14:14 +00:00
|
|
|
echo "Invalid target '${TARGET}'"
|
2016-01-27 00:12:26 +00:00
|
|
|
exit 1
|
|
|
|
esac
|