-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathgetFailedTests.sh
executable file
·104 lines (98 loc) · 4.28 KB
/
getFailedTests.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
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/bash
getFailure() {
cls=$1
type=$2
# echo "Checking $cls for type $type"
#sed -e 's/#27...../;/g' | sed -e 's/< *$//g' | yq -o json -p xml
failures=$(cat ./target/surefire-reports/TEST-"$cls".xml | sed -e 's/#27...../;/g' | sed -e 's/< *$//g' | yq -o json -p xml | gron | grep 'testcase\[[0-9]*\].'$type'\[".*@type"\]' | cut -f 2 -d '[' | cut -f1 -d ']')
for id in $(echo $failures); do
# echo "ID: '$id'"
# xq . ./target/surefire-reports/TEST-$cls.xml | gron | grep "testcase\\[$id\\]\\[\"@name\"\\]" | cut -f2 -d= | tr -d '"; '
m="$(cat ./target/surefire-reports/TEST-$cls.xml | sed -e 's/#27...../;/g' | sed -e 's/< *$//g' | yq -o json -p xml | gron | grep "testcase\\[$id\\]\\[\".*@name\"\\]" | cut -f2 -d= | tr -d '"; ')"
if [ $noreason -eq 1 ]; then
echo "$cls#$m"
else
err="$(cat ./target/surefire-reports/TEST-$cls.xml | sed -e 's/#27...../;/g' | sed -e 's/< *$//g' | yq -o json -p xml | gron | grep "testcase\\[$id\\].$type\\[\".*@type\"\\]" | cut -f2 -d= | tr -d '"; ')"
msg="$(cat ./target/surefire-reports/TEST-$cls.xml | sed -e 's/#27...../;/g' | sed -e 's/< *$//g' | yq -o json -p xml | gron | grep "testcase\\[$id\\].$type\\[\".*@message\"\\]" | cut -f2 -d= | tr -d '"; ')"
echo "$cls#$m - $err ($msg)"
fi
done
if cat ./target/surefire-reports/TEST-"$cls".xml | sed -e 's/#27...../;/g' | sed -e 's/< *$//g' | yq -o json -p xml | gron | grep 'testcase.'$type'\[".*@type"\]' >/dev/null; then
#found single test
m=$(cat ./target/surefire-reports/TEST-"$cls".xml | sed -e 's/#27...../;/g' | sed -e 's/< *$//g' | yq -o json -p xml | gron | grep 'testcase\[".*@name"\]' | cut -f2 -d= | tr -d "!; ')")
if [ $noreason -eq 1 ]; then
echo "$cls#$m"
else
err=$(cat ./target/surefire-reports/TEST-"$cls".xml | sed -e 's/#27...../;/g' | sed -e 's/< *$//g' | yq -o json -p xml | gron | grep 'testcase.'$type'\[".*@type"\]' | cut -f2 -d= | tr -d "!; ')")
msg=$(cat ./target/surefire-reports/TEST-"$cls".xml | sed -e 's/#27...../;/g' | sed -e 's/< *$//g' | yq -o json -p xml | gron | grep 'testcase.'$type'\[".*@message"\]' | cut -f2 -d= | tr -d "!; ')")
echo "$cls#$m - $err ($msg)"
fi
fi
}
noreason=0
nosum=0
while [ $# -ne 0 ]; do
case "$1" in
--noreason)
noreason=1
shift
;;
--nosum)
nosum=1
shift
;;
*)
echo "Error - only --noreason or --noshift allowed! $1 unknown"
exit 1
;;
esac
done
fail=0
for i in $(grep -a "Tests run: .*in " test.log/*.log | cut -f4 -d: | cut -f1 -d,); do
((fail = fail + i))
done
run=0
for i in test.log/*; do
fn=$(basename $i)
fn=src/test/java/$(echo "${fn%%.log}" | tr "." "/").java
testMethods=$(grep -E "@Test" $fn | cut -f2 -d: | grep -vc '^ *//')
testMethods3=$(grep -E '@MethodSource\("getMorphiumInstances"\)' $fn | cut -f2 -d: | grep -vc '^ *//')
testMethods2=$(grep -E '@MethodSource\("getMorphiumInstancesNo.*"\)' $fn | cut -f2 -d: | grep -vc '^ *//')
testMethods1=$(grep -E '@MethodSource\("getMorphiumInstances.*Only"\)' $fn | cut -f2 -d: | grep -vc '^ *//')
# testMethodsP=$(grep -E "@ParameterizedTest" $(grep "$p" files.lst) | cut -f2 -d: | grep -vc '^ *//')
((testMethods = testMethods + 3 * testMethods3 + testMethods2 * 2 + testMethods1))
((run = run + testMethods))
done
# for i in $(grep -a "Tests run: .*in " test.log/*.log | cut -f3 -d: | cut -f1 -d,); do
# ((run = run + i))
# done
err=0
for i in $(grep -a "Tests run: .*in " test.log/*.log | cut -f5 -d: | cut -f1 -d,); do
((err = err + i))
done
((sum = fail + err))
if [ "$nosum" -eq 0 ]; then
echo "Toal tests run : $run"
echo "Total failed : $sum"
echo "Tests failed : $fail"
echo "Tests with errors: $err"
fi
if [ "$fail" -eq 0 ] && [ "$err" -eq 0 ]; then
exit
else
echo ""
for cls in $(grep -E "Tests run: " test.log/* | grep FAILURE | cut -f2 -d! | cut -f4 -d' '); do
# for cls in $(grep -E "] Running |Tests run: " test.log/* | grep -B1 FAILURE | cut -f2 -d']' | grep -v "Tests run: " | sed -e 's/Running //' | grep -v -- '--'); do
# echo "Getting failures in $cls"
if [ ! -e ./target/surefire-reports/TEST-$cls.xml ]; then
# if [ "$noreason" -eq 1 ]; then
echo "$cls"
# else
# echo "$cls (no more details available)"
# fi
continue
fi
getFailure $cls "failure"
getFailure $cls "error"
done
fi