-
Notifications
You must be signed in to change notification settings - Fork 159
/
run_tests.sh
executable file
·91 lines (79 loc) · 2.09 KB
/
run_tests.sh
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash -el
# This script expects environment variables already set, and configures the
# environment before starting the tests. The environment variables can be set
# manually, by matrix_tests.sh or by travis-ci. The script should self-destruct
# after a timeout to avoid running forever with hung tests.
echo "Starting tests..."
killtree() {
local parent=$1 child
if [[ "$1" == "$BASHPID" ]] ; then
return
fi
for child in $(ps -o ppid= -o pid= | awk "\$1==$parent {print \$2}"); do
killtree $child
done
{ kill -0 $parent 2> /dev/null && kill -9 $parent ; } || echo Process $parent finished.
}
# BEGIN TIMEOUT #
TIMEOUT=7200 # 2 hourAllow testss
PROGRESS_INTERVAL=300 # 5 minutes
BOSSPID=$$
(
if [ "${BASH_VERSINFO[0]}" -lt 4 ] ; then
echo "Setting BASHPID for bash < v4"
t="/tmp/$$.sh" ; echo 'echo $PPID' > $t
BASHPID=`bash $t`
rm $t
fi
if [[ "$TRAVIS" = "true" ]] ; then
echo "Wake travis every $PROGRESS_INTERVAL seconds"
timeout $TIMEOUT bash -c -- "while true; do sleep $PROGRESS_INTERVAL ; printf '...';done"
else
echo "Set timeout to $TIMEOUT seconds."
sleep $TIMEOUT
fi
echo
echo "Test timed out after $TIMEOUT seconds."
echo
killtree $BOSSPID
echo
echo Emulator log:
echo
cat adb_logcat.log
echo
echo "Test timed out after $TIMEOUT seconds."
)&
TIMERPID=$!
echo "PIDs: Boss: $BOSSPID, Timer: $TIMERPID"
trap "killtree $TIMERPID" EXIT
# END TIMEOUT #
rake reinstall
ruboto setup -y -t $ANDROID_TARGET
source ~/.rubotorc
ruboto emulator -t $ANDROID_TARGET --no-snapshot
> adb_logcat.log
(gem query -q -i -n ^bundler$ >/dev/null) || gem install bundler
bundle check || bundle install
export NOEXEC_DISABLE=1
rake clean
set +e
if [ "$TEST_NAME" != "" ] ; then
TEST_NAME_ARG="-n $TEST_NAME"
fi
if [ "$TEST_SCRIPT" != "" ] ; then
ruby $TEST_SCRIPT $TEST_NAME_ARG
else
rake test $* $TEST_NAME_ARG
fi
TEST_RC=$?
set -e
echo Tests exited with code $TEST_RC
if [ "$TEST_RC" != "0" ] ; then
echo
echo Emulator log:
echo
cat adb_logcat.log
echo
echo Tests failed with exit code $TEST_RC
fi
exit $TEST_RC