Merge branch 'ci-emulator-tests' into 'master'

CI: run Android tests in an emulator

See #400. Using a WIP merge request to be able to test things on the CI.

See merge request !129
This commit is contained in:
Daniel Martí 2015-09-02 23:28:32 +00:00
commit 7ae6c38e9a
3 changed files with 61 additions and 3 deletions

View File

@ -14,11 +14,26 @@ before_script:
- export PATH="$ANDROID_HOME/tools:$PATH" - export PATH="$ANDROID_HOME/tools:$PATH"
- echo " == Installing Android SDK components" - echo " == Installing Android SDK components"
- echo y | android -s update sdk --no-ui -a -t platform-tools,tools,build-tools-23.0.0,android-22,extra-android-m2repository - echo y | android -s update sdk --no-ui -a -t platform-tools,tools,build-tools-23.0.0,android-22,extra-android-m2repository
- export PATH="$ANDROID_HOME/platform-tools:$PATH"
- export PATH="$ANDROID_HOME/build-tools/23.0.0:$PATH"
- echo " == Installing emulator system images"
- echo y | android -s update sdk --no-ui -a -t android-10
- echo " == Installing Gradle" - echo " == Installing Gradle"
- wget -q -O gradle.zip https://services.gradle.org/distributions/gradle-2.4-bin.zip - wget -q -O gradle.zip https://services.gradle.org/distributions/gradle-2.4-bin.zip
- unzip -q gradle.zip - unzip -q gradle.zip
- export PATH="$PWD/gradle-2.4/bin:$PATH" - export PATH="$PWD/gradle-2.4/bin:$PATH"
build: test:
script: script:
- gradle build - cd F-Droid
- echo " == Building via gradle"
- gradle clean assemble
- echo " == Setting up Android 2.3.7 emulator"
- echo no | android create avd --force -n fcl-test -t android-10 -b armeabi
- echo " == Starting Android 2.3.7 emulator"
- emulator -force-32bit -avd fcl-test -no-skin -no-audio -no-window &
- ./tools/wait-for-emulator
- echo " == Running Android tests"
- gradle connectedAndroidTest
- echo " == Stopping Android 2.3.7 emulator"
- kill $!

View File

@ -123,7 +123,7 @@ public class RepoUpdater {
} }
} }
void processDownloadedFile(File downloadedFile, String cacheTag) throws UpdateException { protected void processDownloadedFile(File downloadedFile, String cacheTag) throws UpdateException {
InputStream indexInputStream = null; InputStream indexInputStream = null;
try { try {
if (downloadedFile == null || !downloadedFile.exists()) if (downloadedFile == null || !downloadedFile.exists())

43
F-Droid/tools/wait-for-emulator Executable file
View File

@ -0,0 +1,43 @@
#!/bin/bash
sec=0
timeout=360
err() {
echo "$@"
exit 1
}
explain() {
if [[ "$1" =~ "not found" ]]; then
printf "device not found"
elif [[ "$1" =~ "offline" ]]; then
printf "device offline"
elif [[ "$1" =~ "running" ]]; then
printf "booting"
else
printf "unknown: $1"
fi
}
while true; do
if [[ $sec -ge $timeout ]]; then
err "Timeout ($timeout seconds) reached - Failed to start emulator"
fi
out=$(adb -e shell getprop init.svc.bootanim 2>&1)
if [[ "$out" =~ "command not found" ]]; then
err "$out"
fi
if [[ "$out" =~ "stopped" ]]; then
break
fi
exp=$(explain "$out")
let "r = sec % 5"
if [[ $r -eq 0 ]]; then
echo "Waiting for emulator to start: $exp"
fi
sleep 1
let "sec++"
done
echo "Emulator is ready"