-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathcompare-gradle-tests-with-ant-tests
executable file
·59 lines (50 loc) · 1.65 KB
/
compare-gradle-tests-with-ant-tests
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
#!/bin/bash
set -o nounset
set -o pipefail
set -o errexit
set -o errtrace
trap 'echo "Error at line $LINENO, exit code $?" >&2' ERR
tmpdir="$(mktemp --directory)"
trap 'rm -rf -- "$tmpdir"' EXIT
from_ant="$(mktemp --tmpdir="$tmpdir" --suffix=.from-ant)"
from_gradle="$(mktemp --tmpdir="$tmpdir" --suffix=.from-gradle)"
if [ -e "./gradlew" ] ; then
echo "Found ./gradlew, using it instead of system's Gradle."
shopt -s expand_aliases
unalias -a
alias gradle=./gradlew
fi
echo "Cleaning Gradle output and testing with Ant..."
gradle clean
ant -Dtest.skip=false clean dist |& tee "${from_ant}.raw"
awk '
length(outbuf) > 0 { if($0 !~ /SKIPPED/) { print outbuf } ; outbuf="" }
/\[junit\] Running (.*)/ { testsuite=$3 }
/\[junit\] Testcase: (.*) took (.*) sec/ { outbuf = testsuite "." $3 "()" }
END { if(length(outbuf) > 0) { print outbuf } }' \
"${from_ant}.raw" | sort > "$from_ant"
echo "Cleaning Ant output and testing with Gradle..."
ant clean
gradle clean test |& tee "${from_gradle}.raw"
awk '/^(.+) > (.+) PASSED$/ { print $1 "." $3 "()" }' \
"${from_gradle}.raw" | sort > "$from_gradle"
# To test whether the diff fails if it should:
#echo a >> "$from_gradle"
echo ""
echo "Ant output: $from_ant"
echo "Gradle output: $from_gradle"
ant_tests=$(wc -l "$from_ant" | cut -d' ' -f1)
gradle_tests=$(wc -l "$from_gradle" | cut -d' ' -f1)
[ "$ant_tests" -gt 0 ]
[ "$gradle_tests" -gt 0 ]
echo "Ant tests: $ant_tests"
echo "Gradle tests: $gradle_tests"
echo "Diffing:"
if diff "$from_ant" "$from_gradle" ; then
echo "Executed tests are identical!"
exit 0
else
echo "Executed tests do not match! Not deleting output so you can inspect it." >&2
trap - EXIT
exit 1
fi