-
Notifications
You must be signed in to change notification settings - Fork 32
/
run-tests.sh
executable file
·57 lines (52 loc) · 1.84 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
#!/usr/bin/env bash
set -e
function finish {
rm -rf target/rerun.txt
}
trap finish EXIT
echo "Ensuring all dependencies are present in LICENSE-3rdparty.csv ..."
# -DoutputType=dot will make output look like:
# [INFO] "org.glassfish.jersey.media:jersey-media-json-jackson:jar:2.27:compile" "org.glassfish.jersey.ext:jersey-entity-filtering:jar:2.27:compile" ;
# * the grep result:
# "org.glassfish.jersey.ext:jersey-entity-filtering:jar:2.27:compile" ;
# * the first sed result:
# org.glassfish.jersey.ext:jersey-entity-filtering:jar:2.27:compile
# * the second sed result
# org.glassfish.jersey.ext:jersey-entity-filtering
MVN_OUTPUT=`mvn dependency:tree -DoutputType=dot`
if [ $? -ne 0 ]; then
echo $MVN_OUTPUT
exit 1
fi
ALL_DEPS=`echo $MVN_OUTPUT | grep -- "-> " | sed 's|.*-> "\(.*\)".*|\1|' | sed "s/\(.*\):jar:.*/\1/" | sort | uniq`
DEPS_NOT_FOUND=""
for one_dep in `echo $ALL_DEPS`; do
set +e
cat LICENSE-3rdparty.csv | grep "$one_dep" > /dev/null 2>&1
if [ $? -ne 0 ]; then
DEPS_NOT_FOUND="${DEPS_NOT_FOUND}\nimport,${one_dep},<LICENSE>,<COPYRIGHT>"
fi
set -e
done
if [ -n "$DEPS_NOT_FOUND" ]; then
echo "Some dependencies were not found in LICENSE-3rdparty.csv, please add: $DEPS_NOT_FOUND"
exit 1
else
echo "LICENSE-3rdparty.csv is up to date"
fi
RERUN_COUNT=$([ "$CI" == "true" ] && echo "1" || echo "0")
set +e
mvn --show-version --batch-mode -Dsurefire.rerunFailingTestsCount=${RERUN_COUNT} test
RESULT=$?
if [ "$RESULT" -ne 0 -a ! -d "target/surefire-reports" ]; then
# No surefire reports and error means compilation error, don't try to rerun
exit $RESULT
fi
if [ "$RERECORD_FAILED_TESTS" == "true" -a "$RESULT" -ne 0 ]; then
set -e
python3 -m pip install -U pip setuptools
python3 -m pip install "junitparser==1.4.1"
python3 failed.py | RECORD=true bash
RESULT=$?
fi
exit $RESULT