-
Notifications
You must be signed in to change notification settings - Fork 20
/
kdetest.sh
124 lines (104 loc) · 2.68 KB
/
kdetest.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# run a given unit-test or all via ctest
set -e
debug=
old_pwd=$(pwd)
cb
if [[ "$1" == "--debug" ]]; then
debug=$1
shift 1
fi
if [[ -d "$1" ]]; then
cd $1
shift 1
elif [[ ! -f "$1" && -d "$(dirname $1)" ]]; then
cd $(dirname $1)
shift 1
fi
tests=$(listCTests $debug)
if [[ "$tests" == "" ]]; then
echo "this directory does not contain any unit tests!"
echo
cd "$old_pwd"
exit 1
fi
base="$HOME/.kde-unit-test"
if [ ! -d "$base" ]; then
mkdir -p $base || exit 1
fi
tmpfile=/tmp/testoutput_$$
trap "rm -rf $tmpfile" EXIT
oldPS1="$PS1"
PS1="TEST:$PS1"
export QT_MESSAGE_PATTERN="%{category} %{function}: %{message} [%{file}:%{line}]"
export XDG_DATA_HOME="$base/local5"
export XDG_CONFIG_HOME="$base/config5"
export XDG_CACHE_HOME="$base/cache5"
if [[ "$1" != "" ]]; then
test=$1
if [[ "$debug" == "--debug" ]]; then
test=${test/.shell/}
fi
shift 1
args=$@
if [ ! -f "$test" ] || ! in_array "$test" $tests ; then
if in_array "$test.shell" $tests; then
test="$test".shell
else
echo "could not find unittest '$test'. available are:"
echo $tests
echo
cd "$old_pwd"
exit 1
fi
fi
if [[ "$debug" != "" ]]; then
gdb --eval-command="run" --args ./$test -maxwarnings 0 $args 2>&1 | tee -a "$tmpfile"
else
./$test -maxwarnings 0 $args 2>&1 | tee -a "$tmpfile"
fi
echo
else
# run all tests
for test in $tests; do
if [[ "$debug" != "" ]]; then
gdb --eval-command="run" --args ./$test -maxwarnings 0 2>&1 | tee -a "$tmpfile"
else
./$test -maxwarnings 0 2>&1 | tee -a "$tmpfile"
fi
done
fi
if [[ "$(grep -c "^RESULT " "$tmpfile")" != 0 ]]; then
echo
echo " --- BENCHMARKS --- "
grep --color=never -A 1 "^RESULT " "$tmpfile"
echo
fi
echo
echo " --- ALL PASSED TESTS --- "
grep --color=never "^PASS " "$tmpfile"
echo
echo $(grep -c "^PASS " "$tmpfile")" passed tests in total"
if [[ "$(grep -c "^XFAIL " "$tmpfile")" != 0 ]]; then
echo
echo " --- EXPECTED FAILURES --- "
perl -ne '(/^^XFAIL/../^ Loc:/) && print' "$tmpfile"
echo
echo $(grep -c "^XFAIL" "$tmpfile")" expected failed tests in total"
echo
fi
if [[ "$(grep -c "^XPASS " "$tmpfile")" != 0 ]]; then
echo
echo " --- UNEXPECTED PASSES --- "
perl -ne '(/^^XPASS/../^ Loc:/) && print' "$tmpfile"
echo
echo $(grep -c "^XPASS" "$tmpfile")" unexpected passed tests in total"
echo
fi
echo
echo " --- ALL FAILED TESTS --- "
perl -ne '(/^^FAIL!/../^ Loc:/) && print' "$tmpfile"
echo
echo $(grep -c "^FAIL!" "$tmpfile")" failed tests in total"
echo
grep --color=never "^QFATAL : " "$tmpfile"
grep --color=never -B 5 "^Segmentation fault" "$tmpfile"