summaryrefslogtreecommitdiffhomepage
path: root/android/scripts
diff options
context:
space:
mode:
authorAlbin <albin@mullvad.net>2023-01-23 12:24:17 +0100
committerAlbin <albin@mullvad.net>2023-01-25 13:26:35 +0100
commit4d67f4393492a3f1df46302b70edf4a6ee0f40bf (patch)
treeb25a0f9f9f43772953e6ef2228ac7cc0ad5f0265 /android/scripts
parent9e61d666c6b5f31d6fe2c42ee517157ab62210cb (diff)
downloadmullvadvpn-4d67f4393492a3f1df46302b70edf4a6ee0f40bf.tar.xz
mullvadvpn-4d67f4393492a3f1df46302b70edf4a6ee0f40bf.zip
Upload report on ci instrumentation test failures
The report includes: * Screenshots * Logcat * Instrumentation logs
Diffstat (limited to 'android/scripts')
-rwxr-xr-xandroid/scripts/run-instrumented-tests.sh21
1 files changed, 16 insertions, 5 deletions
diff --git a/android/scripts/run-instrumented-tests.sh b/android/scripts/run-instrumented-tests.sh
index d020bf88c8..5e855ca242 100755
--- a/android/scripts/run-instrumented-tests.sh
+++ b/android/scripts/run-instrumented-tests.sh
@@ -58,12 +58,20 @@ if [[ -z ${TEST_TYPE-} ]]; then
exit 1
fi
+LOCAL_TMP_REPORT_PATH="/tmp/mullvad-$TEST_TYPE-instrumentation-report"
+INSTRUMENTATION_LOG_FILE_PATH="$LOCAL_TMP_REPORT_PATH/instrumentation-log.txt"
+LOGCAT_FILE_PATH="$LOCAL_TMP_REPORT_PATH/logcat.txt"
+LOCAL_SCREENSHOT_PATH="$LOCAL_TMP_REPORT_PATH/screenshots"
+DEVICE_SCREENSHOT_PATH="/sdcard/Pictures/mullvad-$TEST_TYPE"
+
echo "Preparing to run tests of type: $TEST_TYPE"
echo ""
-echo "### Cleaning up old logs ###"
-LOG_FILE_NAME="mullvad-$TEST_TYPE.txt"
-LOG_FILE_PATH="/tmp/$LOG_FILE_NAME"
+echo "### Ensure clean report structure ###"
+rm -rf "$LOCAL_TMP_REPORT_PATH" || echo "No report path"
+adb logcat --clear
+adb shell rm -rf "$DEVICE_SCREENSHOT_PATH"
+mkdir "$LOCAL_TMP_REPORT_PATH"
echo ""
if [[ "${USE_ORCHESTRATOR-}" == "true" ]]; then
@@ -121,7 +129,7 @@ else
am instrument -w \
$TEST_PACKAGE/androidx.test.runner.AndroidJUnitRunner"
fi
-adb shell "$INSTRUMENTATION_COMMAND" | tee "$LOG_FILE_PATH"
+adb shell "$INSTRUMENTATION_COMMAND" | tee "$INSTRUMENTATION_LOG_FILE_PATH"
echo ""
echo "### Ensure that packages are uninstalled ###"
@@ -132,8 +140,11 @@ adb uninstall androidx.test.orchestrator || echo "Test orchestrator package not
echo ""
echo "### Checking logs for failures ###"
-if grep -q "$LOG_FAILURE_MESSAGE" "$LOG_FILE_PATH"; then
+if grep -q "$LOG_FAILURE_MESSAGE" "$INSTRUMENTATION_LOG_FILE_PATH"; then
echo "One or more tests failed, see logs for more details."
+ echo "Collecting report..."
+ adb pull "$DEVICE_SCREENSHOT_PATH" "$LOCAL_SCREENSHOT_PATH" || echo "No screenshots"
+ adb logcat -d > "$LOGCAT_FILE_PATH"
exit 1
else
echo "No failures!"