forked from sboesebeck/morphium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runtests.sh
84 lines (75 loc) · 2.66 KB
/
runtests.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
#!/bin/bash
function quit {
echo "Shutting down"
kill -9 $(ps aux | grep -v grep | grep surefire | cut -c15-24)
dur=$(date +%s)
let dur=dur-start
let h=dur/3600
let m='(dur-h*3600)/60'
let s='(dur-h*3600-m*60)'
let h=dur/3600; let m='(dur-h*3600)/60';let s='(dur-h*3600-m*60)';
duration=$(printf "Duration: %02d:%02d:%02d" $h $m $s)
end="Aborted during testrun after $duration on jdk $jv, but ran $run Tests, $fail tests failed, $err tests had errors"
curl -X POST -H "Content-type: application/json" --data "{'text':'Morphium $version integration test just ran: $end'}" $(<slackurl.inc)
exit 1
}
trap 'quit' ABRT QUIT INT
jv=$(/usr/libexec/java_home)
jv=${jv%/Contents/Home}
jv=${jv##*/}
echo "Running on $jv"
start=$(date +%s)
cd $(dirname $0)
version=$(grep '<version>' pom.xml | head -n1 | tr -d ' a-z<>/')
mvn -Dsurefire.skipAfterFailureCount=2 -Dsurefire.rerunFailingTestsCount=1 test >test.log 2>&1 &
end=""
while true; do
clear
echo "Running tests for version $version"
date
grep "Running " test.log | tail -n 1
a=$(grep "Number: " test.log | tail -n 1); echo "Test number: ${a##*:}"
run=0
for i in $(grep -a 'Tests run: ' test.log |cut -f2 -d: | cut -f1 -d,); do
let run=run+i
done
echo "Tests run: $run"
fail=0
for i in $(grep -a 'Tests run: ' test.log |cut -f3 -d: | cut -f1 -d,); do
let fail=fail+i
done
echo "Fails: $fail"
err=0
for i in $(grep -a 'Tests run: ' test.log |cut -f4 -d: | cut -f1 -d,); do
let err=err+i
done
echo "Errors: $err"
echo
echo "------------- Current Failed tests:"
if [ $fail -gt 0 ] || [ $err -gt 0 ]; then
egrep "Running |Tests run:" test.log | grep -B1 FAILURE
echo
fi
echo
echo "------------- Log output:"
tail -n 10 test.log
jobs > /dev/null
l=$(ls -l test.log)
sleep 15
if [ $(jobs | wc -l) -eq 0 ]; then
echo "Bg job finished... exiting"
break
fi
done
run=$(grep -a 'Tests run: ' test.log |cut -f2 -d: | cut -f1 -d, | tail -n 1)
fail=$(grep -a 'Tests run: ' test.log |cut -f3 -d: | cut -f1 -d, | tail -n 1)
err=$(grep -a 'Tests run: ' test.log |cut -f4 -d: | cut -f1 -d, | tail -n 1)
dur=$(date +%s)
let dur=dur-start
let h=dur/3600
let m='(dur-h*3600)/60'
let s='(dur-h*3600-m*60)'
let h=dur/3600; let m='(dur-h*3600)/60';let s='(dur-h*3600-m*60)';
duration=$(printf "Duration: %02d:%02d:%02d" $h $m $s)
end="$duration - JDK: $jv - Ran $run Tests, $fail tests failed, $err tests had errors"
curl -X POST -H "Content-type: application/json" --data "{'text':'Morphium $version integration test just ran: $end'}" $(<slackurl.inc)