-
Notifications
You must be signed in to change notification settings - Fork 121
Expand file tree
/
Copy pathmt
More file actions
executable file
·245 lines (218 loc) · 6.75 KB
/
Copy pathmt
File metadata and controls
executable file
·245 lines (218 loc) · 6.75 KB
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
#!/usr/bin/env bash
#
# MT, run all or specific parts of the test suite
# Copyright (C) 2018-2026 Xavier Delaruelle
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
##########################################################################
set -u
# print help message
echo_usage() {
echo "Usage: $0 [options] [testsuite] [serienum[/testfilenum]]...
Run all or specific parts of the test suite
Test suites:
modules Test modulecmd.tcl built script (default)
quick Short version of modulecmd.tcl testsuite
cov Coverage mode of modulecmd.tcl testsuite
install Test Modules installation
lint Lint script files of this repository
Select parts of testsuite:
serienum Identification number of testsuite directory containing a
series of testfile (e.g., '50' for modules.50-cmds dir.)
testfilenum Identification number of testfile in a testserie (e.g.,
'370' for 370-variant.exp testfile in modules.70-maint dir.)
Options:
-h, --help Show this help message and exit
Examples:
$0
$0 quick
$0 lint
$0 50/37 61 70/{290,440}
"
}
# print message on stderr then exit
echo_error() {
echo -e "ERROR: $1" >&2
exit 1
}
# process log file to highlight failed tests
review_log() {
if [ -e $testserie.log ]; then
script/mtreview $testserie.log
fi
}
if [ ! -e tcl/main.tcl.in ]; then
echo_error "Not in correct directory"
fi
# make bin, should use GNU make
if command -v gmake >/dev/null; then
make='gmake'
else
make='make'
fi
# make target
target='test'
testserie='modules'
setuptestfiles=(00/005 00/006 00/010 00/050 00/060 00/080 00/085)
if [ $# -gt 0 ]; then
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
echo_usage
exit 0
elif [ "$1" = "modules" ]; then
target='test'
testserie='modules'
shift
elif [ "$1" = "quick" ]; then
export QUICKTEST=1
shift
elif [ "$1" = "cov" ]; then
export COVERAGE=y
shift
elif [ "$1" = "install" ]; then
target='testinstall'
testserie='install'
setuptestfiles=(00/005 00/006 00/010 00/011)
shift
elif [ "$1" = "lint" ]; then
target='testlint'
testserie='lint'
setuptestfiles=(00/005 00/006 00/011)
shift
fi
fi
if [ $# -gt 0 ]; then
# build list of test files to run test on
declare -a testfiles
for i in "${setuptestfiles[@]}" "${@}"; do
j=${i##*/}
i=${i%/*}
# add all test files if passed a full section number or a test file
# from collection section (this section must be run entirely)
if [ "$j" == "$i" ] || [ "$i" == "61" ]; then
testfiles+=(testsuite/"$testserie.${i}"*/*.exp)
else
testfiles+=(testsuite"/$testserie.${i}"*/{010,999,$j}*.exp)
fi
done
# get file name of selected test files (runtest requires .exp file name)
declare -a testfnames=()
for i in "${testfiles[@]}"; do
if [ -e "$i" ]; then
fname=${i##*/}
# build list of unique file names
if [ ${#testfnames[@]} -eq 0 ]\
|| [[ ! " ${testfnames[*]} " == *" $fname "* ]]; then
testfnames+=("$fname")
fi
fi
done
# pass list to make target
export RUNTESTFILES="${testfnames[*]}"
fi
# attempt to get enhanced diff tool but disable this retrieval if download
# tentative fails
if [ ! -e .noicdiff ]; then
$make icdiff || touch .noicdiff
fi
rm -f $testserie.log
if [ -t 1 ]; then
fail_count=0
xfail_count=0
pass_count=0
error_count=0
current_fail_count=0
current_xfail_count=0
current_pass_count=0
current_error_count=0
current_case=''
pass_sgr='1;32;7'
fail_sgr=0
error_sgr=0
tail --follow=name --retry --quiet $testserie.log \
| while read -r logline; do
case_changed=0
case "$logline" in
PASS*)
((pass_count++))
((current_pass_count++)) ;;
FAIL*)
((fail_count++))
((current_fail_count++)) ;;
XFAIL*)
((xfail_count++))
((current_xfail_count++)) ;;
ERROR:\ tcl\ error\ sourcing*)
((error_count++))
((current_error_count++)) ;;
Running*)
case_raw=${logline/*${testserie}.}
case_suite=${case_raw:0:2}
number_raw=${case_raw#*/}
case_number=${number_raw:0:3}
previous_case=$current_case
current_case="$case_suite/$case_number"
case_changed=1 ;;
esac
if [ $error_count -eq 1 ]; then
pass_sgr=0
fail_sgr=0
error_sgr='1;35;7'
elif [ $error_count -eq 0 ] && [ $fail_count -eq 1 ]; then
pass_sgr=0
fail_sgr='1;31;7'
fi
if [ $case_changed -eq 1 ] ; then
if [ $current_fail_count -ne 0 ] || [ $current_xfail_count -ne 0 ]\
|| [ $current_error_count -ne 0 ]; then
issue_info="case=$previous_case, "
issue_info+="pass=$current_pass_count, "
issue_info+="fail=$current_fail_count, "
issue_info+="xfail=$current_xfail_count, "
issue_info+="error=$current_error_count"
echo -e "\e[1A\e[Kissue: $issue_info"
echo
fi
current_fail_count=0
current_xfail_count=0
current_pass_count=0
current_error_count=0
progress_info="current=$current_case, "
progress_info+="\e[${pass_sgr}mpass=$pass_count\e[0m, "
progress_info+="\e[${fail_sgr}mfail=$fail_count\e[0m, "
progress_info+="xfail=$xfail_count, "
progress_info+="\e[${error_sgr}merror=$error_count\e[0m"
echo -e "\e[1A\e[Kprogress: $progress_info"
fi
done &
# ensure log analysis is stopped when script finishes or if aborted
trap 'kill $! 2>/dev/null' EXIT
fi
# parse errors in log even if full run is aborted
trap 'review_log && exit 1' SIGINT
export RUNTESTFLAGS='-v -v >/dev/null 2>&1'
$make $target
ret=$?
if [ -t 1 ]; then
kill $!
fi
# highlight failed tests
retreview=0
review_log
retreview+=$?
# testsuite ok but mtreview failed to run
if [ $ret -eq 0 ] && [ $retreview -ne 0 ]; then
ret=$retreview
fi
exit $ret
# vim:set tabstop=3 shiftwidth=3 expandtab autoindent: