-
Notifications
You must be signed in to change notification settings - Fork 131
Expand file tree
/
Copy pathrun-code-coverage.sh
More file actions
executable file
·62 lines (51 loc) · 2.03 KB
/
Copy pathrun-code-coverage.sh
File metadata and controls
executable file
·62 lines (51 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
# We can't run emulator as a daemon
# VSTS will not execute next step until emulator killed
# So we need to run tests in same step...
export DYLD_LIBRARY_PATH="$ANDROID_HOME/emulator/lib64/qt/lib"
$ANDROID_HOME/emulator/emulator -avd emulator -skin 768x1280 -no-window -gpu off -no-metrics -no-audio -no-boot-anim -camera-back none -camera-front none &
# Ensure Android Emulator has booted successfully before continuing
EMU_BOOTED='unknown'
while [[ ${EMU_BOOTED} != *"stopped"* ]]; do
echo "Waiting emulator to start..."
sleep 5
EMU_BOOTED=`adb shell getprop init.svc.bootanim || echo unknown`
done
duration=$(( SECONDS - start ))
echo "Android Emulator started after $duration seconds."
# Convert VSTS variables to coveralls for reporting status on github.
if [[ "$LOGNAME" -eq "vsts" ]];
then
export CI_NAME="vsts"
# For pull request we need to expose the number to the gradle plugin.
if [[ $BUILD_SOURCEBRANCH =~ ^refs/pull/[0-9]+/merge$ ]]
then
export CI_PULL_REQUEST=`sed -E 's#refs/pull/([0-9]+)/merge#\1#' <<< $BUILD_SOURCEBRANCH`
fi
# For branches (after merging), we need to attach to branch name in git
# VSTS checkouts in detached mode
# and the branch env variable does not work with the gradle plugin...
if [[ $BUILD_SOURCEBRANCH =~ ^refs/heads/.*$ ]]
then
BRANCH=`sed -E 's#refs/heads/(.*)#\1#' <<< $BUILD_SOURCEBRANCH`
git checkout -b $BRANCH
fi
fi
# Wait for 30 seconds before running tests to prevent install exception
echo "Waiting for 30 seconds..."
sleep 30
# Run tests with coverage
if [ -z $1 ]
then
# Using env variable COVERALLS_REPO_TOKEN if set, this will not fail process unset.
./gradlew coveralls
else
# Expose variable just for this run based on script parameter.
COVERALLS_REPO_TOKEN=$1 ./gradlew coveralls
fi
EXIT_CODE=$?
# And kill emulator
adb emu kill
# use gradle exit code, we can't use set -e as we need to kill emulator.
# also if starting emulator fails, gradle will fail, so we can just test gradle.
exit $EXIT_CODE