Niedzielski has uploaded a new change for review. https://gerrit.wikimedia.org/r/239898
Change subject: Add CI script for testing emulator readiness ...................................................................... Add CI script for testing emulator readiness The Android instrumentation tests are failing in a strange way after upgrading the Android Support libraries[0]: com.android.builder.testing.api.TestException: com.android.builder.testing.api.DeviceException: com.android.ddmlib.ShellCommandUnresponsiveException This script performs some device readiness checks and waits as needed before returning which allows the tests to run successfully again. [0] https://gerrit.wikimedia.org/r/#/c/235859/ Change-Id: Ib8a04d12ec48fe03c508fcacd355daa20a92b34d --- A scripts/adb-setup.sh 1 file changed, 55 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/apps/android/wikipedia refs/changes/98/239898/1 diff --git a/scripts/adb-setup.sh b/scripts/adb-setup.sh new file mode 100755 index 0000000..cffbd7c --- /dev/null +++ b/scripts/adb-setup.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash +# initializes a device for testing and returns when ready. all arguments are +# passed to adb +case $- in *i*) :;; *) set -euo pipefail;; esac + +# ------------------------------------------------------------------------------ +declare ADB_ARGS=() + +# ------------------------------------------------------------------------------ +# adb with any script arguments +adb() { + command adb ${ADB_ARGS:+"${ADB_ARGS[@]}"} "$@" +} + +is-booted() { + [[ "$(adb shell getprop sys.boot_completed|tr -d '\r')" == 1 ]] +} + +wait-for-boot() { + while ! is-booted && sleep 1; do :; done +} + +wait-for-internet-ping() { + # nc isn't always available + adb shell 'ping -c1 wikipedia.org > /dev/null && echo ok'| + grep -q ok +} + +wait-for-internet-nc() { + # ping always fails on the API 15 emulator + adb shell "echo -e 'GET / HTTP/1.1\n'|nc wikipedia.org 80"| + grep -q 'HTTP/[0-9].[0-9] 200 OK' +} + +wait-for-internet() { + wait-for-internet-nc || wait-for-internet-ping +} + +unlock-screen() { + # http://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_MENU + declare -i KEYCODE_MENU=82 + adb shell input keyevent $KEYCODE_MENU +} + +# ------------------------------------------------------------------------------ +main() { + ADB_ARGS=("$@") + adb wait-for-device + wait-for-boot + wait-for-internet + unlock-screen +} + +# ------------------------------------------------------------------------------ +case $- in *i*) :;; *) main "$@";; esac \ No newline at end of file -- To view, visit https://gerrit.wikimedia.org/r/239898 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib8a04d12ec48fe03c508fcacd355daa20a92b34d Gerrit-PatchSet: 1 Gerrit-Project: apps/android/wikipedia Gerrit-Branch: master Gerrit-Owner: Niedzielski <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
