mirror of https://github.com/iSoron/uhabits.git
parent
6838a0f2d3
commit
37e1a6233c
@ -0,0 +1,53 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
PACKAGE_NAME=org.isoron.uhabits
|
||||||
|
OUTPUT_DIR=app/build/outputs
|
||||||
|
LOG=${OUTPUT_DIR}/test.log
|
||||||
|
|
||||||
|
info() {
|
||||||
|
local COLOR='\033[1;32m'
|
||||||
|
local NC='\033[0m'
|
||||||
|
echo -e " $COLOR*$NC $1"
|
||||||
|
}
|
||||||
|
|
||||||
|
info "Cleaning output directory..."
|
||||||
|
rm -rf ${OUTPUT_DIR}
|
||||||
|
mkdir -p ${OUTPUT_DIR}
|
||||||
|
|
||||||
|
info "Building and installing APK..."
|
||||||
|
./gradlew assembleDebug assembleAndroidTest >> $LOG 2>> $LOG || exit 1
|
||||||
|
adb install -r ${OUTPUT_DIR}/apk/app-debug.apk >> $LOG 2>> $LOG || exit 1
|
||||||
|
adb install -r ${OUTPUT_DIR}/apk/app-debug-androidTest-unaligned.apk \
|
||||||
|
>> $LOG 2>> $LOG || exit 1
|
||||||
|
|
||||||
|
info "Granting permission to disable animations..."
|
||||||
|
adb shell pm grant org.isoron.uhabits android.permission.SET_ANIMATION_SCALE \
|
||||||
|
>> $LOG 2>> $LOG || exit 1
|
||||||
|
|
||||||
|
info "Running tests..."
|
||||||
|
adb shell am instrument \
|
||||||
|
-e coverage true $* \
|
||||||
|
-w ${PACKAGE_NAME}.test/android.support.test.runner.AndroidJUnitRunner \
|
||||||
|
| tee ${OUTPUT_DIR}/runner.txt \
|
||||||
|
| tee -a $LOG
|
||||||
|
grep -q "FAILURES\!\!\!" ${OUTPUT_DIR}/runner.txt && failed=1
|
||||||
|
|
||||||
|
info "Fetching failed generated files..."
|
||||||
|
mkdir -p ${OUTPUT_DIR}/failed
|
||||||
|
adb pull /sdcard/Android/data/${PACKAGE_NAME}/cache/Failed \
|
||||||
|
${OUTPUT_DIR}/failed >> $LOG 2>> $LOG
|
||||||
|
adb shell rm -r /sdcard/Android/data/${PACKAGE_NAME}/cache/ >> $LOG 2>> $LOG
|
||||||
|
|
||||||
|
info "Fetching logcat..."
|
||||||
|
adb logcat -d > ${OUTPUT_DIR}/logcat.txt
|
||||||
|
|
||||||
|
info "Building coverage report..."
|
||||||
|
mkdir -p ${OUTPUT_DIR}/code-coverage/connected/
|
||||||
|
adb pull /data/data/${PACKAGE_NAME}/files/coverage.ec \
|
||||||
|
${OUTPUT_DIR}/code-coverage/connected/ >> $LOG 2>> $LOG
|
||||||
|
./gradlew app:createDebugCoverageReport \
|
||||||
|
-x app:connectedDebugAndroidTest >> $LOG 2>> $LOG
|
||||||
|
|
||||||
|
info "Uninstalling test APK..."
|
||||||
|
adb uninstall ${PACKAGE_NAME}.test >> $LOG 2>> $LOG
|
||||||
|
|
||||||
|
exit $failed
|
Loading…
Reference in new issue