mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 17:18:52 -06:00
Update run scripts
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
# Loop Habit Tracker
|
# Loop Habit Tracker
|
||||||
|
|
||||||
<a href="https://gemini.isoron.org:8111/?guest=1">
|
<a href="http://build.loophabits.org:8111/?guest=1">
|
||||||
<img src="http://gemini.isoron.org:8111/app/rest/builds/buildType(id:LooppHabitTracker_Build)/statusIcon">
|
<img src="http://build.loophabits.org:8111/app/rest/builds/buildType(id:LooppHabitTracker_BuildNougat)/statusIcon">
|
||||||
</a>
|
</a>
|
||||||
<a href="https://codecov.io/github/iSoron/uhabits?branch=dev">
|
<a href="https://codecov.io/github/iSoron/uhabits?branch=dev">
|
||||||
<img src="https://img.shields.io/codecov/c/github/iSoron/uhabits.svg" alt="Coverage via Codecov" />
|
<img src="https://img.shields.io/codecov/c/github/iSoron/uhabits.svg" alt="Coverage via Codecov" />
|
||||||
|
|||||||
95
run_tests
95
run_tests
@@ -1,69 +1,90 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
PACKAGE_NAME=org.isoron.uhabits
|
PACKAGE_NAME=org.isoron.uhabits
|
||||||
OUTPUT_DIR=app/build/outputs
|
OUTPUT_DIR=app/build/outputs
|
||||||
LOG=${OUTPUT_DIR}/test.log
|
|
||||||
|
AVD_NAME=$1
|
||||||
|
AVD_SERIAL=$2
|
||||||
|
|
||||||
|
GRADLE="./gradlew --no-daemon --stacktrace"
|
||||||
|
ADB="adb -s emulator-${AVD_SERIAL}"
|
||||||
|
|
||||||
info() {
|
info() {
|
||||||
local COLOR='\033[1;32m'
|
local COLOR='\033[1;32m'
|
||||||
local NC='\033[0m'
|
local NC='\033[0m'
|
||||||
echo -e " $COLOR*$NC $1"
|
#echo -e " $COLOR*$NC $1"
|
||||||
|
echo "###teamcity[progressMessage '$1']"
|
||||||
}
|
}
|
||||||
|
|
||||||
fail() {
|
fail() {
|
||||||
cat $LOG
|
$ADB shell reboot -p
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
info "Running adb as root..."
|
#--------------------------------------------------------------------------------
|
||||||
adb root
|
info "Starting emulator"
|
||||||
|
$ANDROID_HOME/tools/emulator \
|
||||||
|
-avd ${AVD_NAME} -port ${AVD_SERIAL} -no-audio -no-window &
|
||||||
|
$ADB wait-for-device
|
||||||
|
sleep 10
|
||||||
|
|
||||||
info "Cleaning output directory..."
|
#--------------------------------------------------------------------------------
|
||||||
|
info "Running adb as root"
|
||||||
|
$ADB root
|
||||||
|
|
||||||
|
#--------------------------------------------------------------------------------
|
||||||
|
info "Cleaning output directory"
|
||||||
rm -rf ${OUTPUT_DIR}
|
rm -rf ${OUTPUT_DIR}
|
||||||
mkdir -p ${OUTPUT_DIR}
|
mkdir -p ${OUTPUT_DIR}
|
||||||
|
|
||||||
info "Running JVM tests..."
|
#--------------------------------------------------------------------------------
|
||||||
./gradlew :app:testDebugUnitTest >> $LOG 2>> $LOG || fail
|
info "Building instrumentation APKs"
|
||||||
|
$GRADLE --no-daemon assembleDebug assembleAndroidTest || fail
|
||||||
|
|
||||||
info "Building instrumentation APKs..."
|
#--------------------------------------------------------------------------------
|
||||||
./gradlew assembleDebug assembleAndroidTest >> $LOG 2>> $LOG || fail
|
info "Installing APK"
|
||||||
|
$ADB install -r ${OUTPUT_DIR}/apk/app-debug.apk || fail
|
||||||
|
$ADB install -r ${OUTPUT_DIR}/apk/app-debug-androidTest.apk || fail
|
||||||
|
|
||||||
info "Installing APK..."
|
#--------------------------------------------------------------------------------
|
||||||
adb install -r ${OUTPUT_DIR}/apk/app-debug.apk >> $LOG 2>> $LOG || fail
|
info "Granting permissions"
|
||||||
adb install -r ${OUTPUT_DIR}/apk/app-debug-androidTest.apk \
|
$ADB shell pm grant org.isoron.uhabits android.permission.SET_ANIMATION_SCALE || fail
|
||||||
>> $LOG 2>> $LOG || fail
|
|
||||||
|
|
||||||
info "Granting permissions..."
|
#--------------------------------------------------------------------------------
|
||||||
adb shell pm grant org.isoron.uhabits android.permission.SET_ANIMATION_SCALE \
|
info "Running instrumentation tests"
|
||||||
>> $LOG 2>> $LOG || fail
|
$ADB shell am instrument \
|
||||||
|
|
||||||
info "Running instrumentation tests..."
|
|
||||||
adb shell am instrument \
|
|
||||||
-e coverage true -e size medium \
|
-e coverage true -e size medium \
|
||||||
-w ${PACKAGE_NAME}.test/android.support.test.runner.AndroidJUnitRunner \
|
-w ${PACKAGE_NAME}.test/android.support.test.runner.AndroidJUnitRunner \
|
||||||
| tee ${OUTPUT_DIR}/runner.txt \
|
| tee ${OUTPUT_DIR}/runner.txt || fail
|
||||||
| tee -a $LOG
|
|
||||||
grep -q "Error" ${OUTPUT_DIR}/runner.txt && failed=1
|
grep -q "Error" ${OUTPUT_DIR}/runner.txt && failed=1
|
||||||
|
|
||||||
info "Fetching failed generated files..."
|
#--------------------------------------------------------------------------------
|
||||||
|
info "Fetching failed generated files"
|
||||||
mkdir -p ${OUTPUT_DIR}/failed
|
mkdir -p ${OUTPUT_DIR}/failed
|
||||||
adb pull /mnt/sdcard/test-screenshots/ ${OUTPUT_DIR}/failed >> $LOG 2>> $LOG
|
$ADB pull /mnt/sdcard/test-screenshots/ ${OUTPUT_DIR}/failed
|
||||||
adb pull /storage/sdcard/test-screenshots/ ${OUTPUT_DIR}/failed >> $LOG 2>> $LOG
|
$ADB pull /storage/sdcard/test-screenshots/ ${OUTPUT_DIR}/failed
|
||||||
adb pull /sdcard/Android/data/${PACKAGE_NAME}/files/test-screenshots/ ${OUTPUT_DIR}/failed >> $LOG 2>> $LOG
|
$ADB pull /sdcard/Android/data/${PACKAGE_NAME}/files/test-screenshots/ ${OUTPUT_DIR}/failed
|
||||||
|
|
||||||
adb shell rm -r /mnt/sdcard/test-screenshots/ >> $LOG 2>> $LOG
|
$ADB shell rm -r /mnt/sdcard/test-screenshots/
|
||||||
adb shell rm -r /storage/sdcard/test-screenshots/ >> $LOG 2>> $LOG
|
$ADB shell rm -r /storage/sdcard/test-screenshots/
|
||||||
adb shell rm -r /sdcard/Android/data/${PACKAGE_NAME}/files/test-screenshots/ >> $LOG 2>> $LOG
|
$ADB shell rm -r /sdcard/Android/data/${PACKAGE_NAME}/files/test-screenshots/
|
||||||
|
|
||||||
info "Fetching logcat..."
|
#--------------------------------------------------------------------------------
|
||||||
adb logcat -d > ${OUTPUT_DIR}/logcat.txt
|
info "Fetching logcat"
|
||||||
|
$ADB logcat -d > ${OUTPUT_DIR}/logcat.txt
|
||||||
|
|
||||||
info "Building coverage report..."
|
#--------------------------------------------------------------------------------
|
||||||
|
info "Building coverage report"
|
||||||
mkdir -p ${OUTPUT_DIR}/code-coverage/connected/
|
mkdir -p ${OUTPUT_DIR}/code-coverage/connected/
|
||||||
adb pull /data/user/0/${PACKAGE_NAME}/files/coverage.ec \
|
$ADB pull /data/user/0/${PACKAGE_NAME}/files/coverage.ec \
|
||||||
${OUTPUT_DIR}/code-coverage/connected/ >> $LOG 2>> $LOG
|
${OUTPUT_DIR}/code-coverage/connected/
|
||||||
./gradlew coverageReport >> $LOG 2>> $LOG
|
$GRADLE --no-daemon coverageReport || fail
|
||||||
|
|
||||||
info "Uninstalling test APK..."
|
#--------------------------------------------------------------------------------
|
||||||
adb uninstall ${PACKAGE_NAME}.test >> $LOG 2>> $LOG
|
info "Uninstalling test APK"
|
||||||
|
$ADB uninstall ${PACKAGE_NAME}.test || fail
|
||||||
|
|
||||||
|
#--------------------------------------------------------------------------------
|
||||||
|
info "Stopping emulator"
|
||||||
|
$ADB shell reboot -p
|
||||||
|
|
||||||
exit $failed
|
exit $failed
|
||||||
|
|||||||
Reference in New Issue
Block a user