forked from cryostatio/cryostat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
repeated-unit-tests.bash
executable file
·54 lines (44 loc) · 969 Bytes
/
repeated-unit-tests.bash
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
#!/bin/bash
# shellcheck disable=SC2188
set -o pipefail
failures=0
numeric='^[0-9]+$'
if [[ "$1" =~ $numeric ]]; then
runs="$1"
else
runs=1
fi
if [ -z "${MVN}" ]; then
MVN="$(which mvn)"
fi
FLAGS=(
"-Dheadless=true"
"test-compile"
"surefire:test"
)
if [ -n "$2" ]; then
FLAGS+=("-Dtest=$2")
fi
if command -v ansi2txt >/dev/null; then
FLAGS+=("-Dstyle.color=always")
PIPECLEANER="ansi2txt"
else
PIPECLEANER="cat"
fi
DIR="$(dirname "$(readlink -f "$0")")"
runcount=0
while [ "${runcount}" -lt "${runs}" ]; do
logfile="$DIR/target/cryostat-unittests-$(date -Iminutes).log"
mkdir -p "$(dirname logfile)"
>"${logfile}"
if ! "${MVN}" "${FLAGS[@]}" |& tee >($PIPECLEANER > "${logfile}"); then
failures=$((failures+1))
fi
runcount=$((runcount+1))
done
echo
echo "########################"
echo "Test runs completed"
echo "Failures: ${failures}"
echo "Runs: ${runcount}/${runs}"
exit ${failures}