2022-11-27 11:27:06 -05:00
|
|
|
#!/bin/bash
|
2022-11-27 22:33:41 -05:00
|
|
|
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
|
|
|
|
|
|
|
pushd $SCRIPTDIR 2>/dev/null
|
2022-11-27 11:27:06 -05:00
|
|
|
if [[ "$1" == "wasm" ]]; then
|
2023-09-09 18:35:25 -04:00
|
|
|
WASM_BINDGEN_TEST_TIMEOUT=120 wasm-pack test --firefox --headless --no-default-features --features=rt-wasm-bindgen
|
2022-11-27 22:33:41 -05:00
|
|
|
elif [[ "$1" == "ios" ]]; then
|
|
|
|
SYMROOT=/tmp/testout
|
|
|
|
APPNAME=veilidtools-tests
|
|
|
|
BUNDLENAME=com.veilid.veilidtools-tests
|
2022-11-29 12:16:28 -05:00
|
|
|
ID="$2"
|
|
|
|
if [[ "$ID" == "" ]]; then
|
|
|
|
echo "No emulator ID specified"
|
|
|
|
exit 1
|
|
|
|
fi
|
2022-11-27 22:33:41 -05:00
|
|
|
|
2022-11-29 12:16:28 -05:00
|
|
|
# Build for simulator
|
2022-11-27 22:33:41 -05:00
|
|
|
xcrun xcodebuild -project src/tests/ios/$APPNAME/$APPNAME.xcodeproj/ -scheme $APPNAME -destination "generic/platform=iOS Simulator" SYMROOT=$SYMROOT
|
2022-11-29 12:16:28 -05:00
|
|
|
|
|
|
|
# Run in temporary simulator
|
2022-11-27 22:33:41 -05:00
|
|
|
xcrun simctl install $ID $SYMROOT/Debug-iphonesimulator/$APPNAME.app
|
2022-12-01 16:49:37 -05:00
|
|
|
xcrun simctl spawn $ID log stream --level debug --predicate "subsystem == \"$BUNDLENAME\"" &
|
2022-11-27 22:33:41 -05:00
|
|
|
xcrun simctl launch --console $ID $BUNDLENAME
|
2022-12-01 16:49:37 -05:00
|
|
|
sleep 1 # Ensure the last log lines print
|
|
|
|
kill -INT %1
|
2022-11-29 12:16:28 -05:00
|
|
|
|
|
|
|
# Clean up build output
|
2022-11-27 22:33:41 -05:00
|
|
|
rm -rf /tmp/testout
|
2022-11-29 12:16:28 -05:00
|
|
|
|
|
|
|
elif [[ "$1" == "android" ]]; then
|
|
|
|
ID="$2"
|
|
|
|
if [[ "$ID" == "" ]]; then
|
|
|
|
echo "No emulator ID specified"
|
|
|
|
exit 1
|
|
|
|
fi
|
2022-11-30 09:39:12 -05:00
|
|
|
APPNAME=veilid_tools_android_tests
|
|
|
|
APPID=com.veilid.veilid_tools_android_tests
|
2022-11-29 12:16:28 -05:00
|
|
|
ACTIVITYNAME=MainActivity
|
|
|
|
pushd src/tests/android/$APPNAME >/dev/null
|
|
|
|
# Build apk
|
|
|
|
./gradlew assembleDebug
|
|
|
|
# Wait for boot
|
|
|
|
adb -s $ID wait-for-device
|
|
|
|
# Install app
|
|
|
|
adb -s $ID install -r ./app/build/outputs/apk/debug/app-debug.apk
|
|
|
|
# Start activity
|
|
|
|
adb -s $ID shell am start-activity -W $APPID/.$ACTIVITYNAME
|
|
|
|
# Get the pid of the program
|
|
|
|
APP_PID=`adb -s $ID shell pidof -s $APPID`
|
|
|
|
# Print the logcat
|
2022-11-30 09:39:12 -05:00
|
|
|
adb -s $ID shell logcat --pid=$APP_PID veilid-tools:V *:S &
|
2022-11-29 12:16:28 -05:00
|
|
|
# Wait for the pid to be done
|
|
|
|
while [ "$(adb -s $ID shell pidof -s $APPID)" != "" ]; do
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
# Terminate logcat
|
|
|
|
kill %1
|
|
|
|
# Finished
|
|
|
|
popd >/dev/null
|
|
|
|
|
2022-11-27 11:27:06 -05:00
|
|
|
else
|
2023-09-01 17:56:43 -04:00
|
|
|
cargo test -- --nocapture
|
|
|
|
cargo test --features=tracing -- --nocapture
|
|
|
|
cargo test --no-default-features --features=rt-async-std -- --nocapture
|
|
|
|
cargo test --no-default-features --features=rt-async-std,tracing -- --nocapture
|
2022-11-27 11:27:06 -05:00
|
|
|
fi
|
2022-11-27 22:33:41 -05:00
|
|
|
popd 2>/dev/null
|