tests: give few aclocal tests more significant names
[automake.git] / t / ax / tap-summary-aux.sh
blobd86981fde1949392a07cf20bb31f782fe70791f3
1 #! /bin/sh
2 # Copyright (C) 2011-2012 Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
7 # any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # Auxiliary script for tests on TAP support: checking testsuite summary.
19 . test-init.sh
21 br='============================================================================'
23 case $use_colors in
24 yes|no) ;;
25 *) fatal_ "invalid \$use_colors value '$use_colors'"
26 esac
28 fetch_tap_driver
30 cat > configure.ac <<END
31 AC_INIT([GNU AutoTAP], [5.12], [bug-automake@gnu.org])
32 AM_INIT_AUTOMAKE
33 AC_CONFIG_FILES([Makefile])
34 AC_OUTPUT
35 END
37 cat > Makefile.am << 'END'
38 TEST_LOG_DRIVER = $(srcdir)/tap-driver
39 TEST_LOG_COMPILER = cat
40 TESTS = all.test
41 END
43 # The following shell variables are influential for this function:
44 # - expect_failure
45 # - use_colors
46 do_check ()
48 case $#,$1 in
49 1,--pass) expect_failure=no;;
50 1,--fail) expect_failure=yes;;
51 *) fatal_ "invalid usage of 'do_check'";;
52 esac
53 shift
54 cat > summary.exp
55 cat all.test
56 st=0
57 if test $use_colors = yes; then
58 # Forced colorization should take place also with non-ANSI terminals;
59 # hence the "TERM=dumb" definition.
60 make_cmd="env TERM=dumb AM_COLOR_TESTS=always $MAKE -e"
61 else
62 make_cmd=$MAKE
64 $make_cmd check > stdout || st=$?
65 cat stdout
66 if test $expect_failure = yes; then
67 test $st -gt 0 || exit 1
68 else
69 test $st -eq 0 || exit 1
71 $PERL "$am_testaux_srcdir"/extract-testsuite-summary.pl stdout >summary.got \
72 || fatal_ "cannot extract testsuite summary"
73 cat summary.exp
74 cat summary.got
75 if test $use_colors = yes; then
76 # Use cmp, not diff, because the files might contain binary data.
77 compare=cmp
78 else
79 compare=diff
81 $compare summary.exp summary.got || exit 1
84 if test $use_colors = yes; then
85 red="$esc[0;31m"
86 grn="$esc[0;32m"
87 lgn="$esc[1;32m"
88 blu="$esc[1;34m"
89 mgn="$esc[0;35m"
90 brg="$esc[1m"
91 std="$esc[m"
92 else
93 red= grn= lgn= blu= mgn= brg= std=
96 success_header="\
97 ${grn}${br}${std}
98 ${grn}Testsuite summary for GNU AutoTAP 5.12${std}
99 ${grn}${br}${std}"
101 success_footer=${grn}${br}${std}
103 failure_header="\
104 ${red}${br}${std}
105 ${red}Testsuite summary for GNU AutoTAP 5.12${std}
106 ${red}${br}${std}"
108 failure_footer="\
109 ${red}${br}${std}
110 ${red}See ./test-suite.log${std}
111 ${red}Please report to bug-automake@gnu.org${std}
112 ${red}${br}${std}"
114 $ACLOCAL
115 $AUTOCONF
116 $AUTOMAKE --add-missing
118 ./configure
120 # 1 pass.
121 { echo 1..1 && echo ok; } > all.test
122 do_check --pass <<END
123 $success_header
124 ${brg}# TOTAL: 1${std}
125 ${grn}# PASS: 1${std}
126 # SKIP: 0
127 # XFAIL: 0
128 # FAIL: 0
129 # XPASS: 0
130 # ERROR: 0
131 $success_footer
134 # 1 skip.
135 { echo 1..1 && echo 'ok # SKIP'; } > all.test
136 do_check --pass <<END
137 $success_header
138 ${brg}# TOTAL: 1${std}
139 # PASS: 0
140 ${blu}# SKIP: 1${std}
141 # XFAIL: 0
142 # FAIL: 0
143 # XPASS: 0
144 # ERROR: 0
145 $success_footer
148 # 1 xfail.
149 { echo 1..1 && echo 'not ok # TODO'; } > all.test
150 do_check --pass <<END
151 $success_header
152 ${brg}# TOTAL: 1${std}
153 # PASS: 0
154 # SKIP: 0
155 ${lgn}# XFAIL: 1${std}
156 # FAIL: 0
157 # XPASS: 0
158 # ERROR: 0
159 $success_footer
162 # 1 fail.
163 { echo 1..1 && echo not ok; } > all.test
164 do_check --fail <<END
165 $failure_header
166 ${brg}# TOTAL: 1${std}
167 # PASS: 0
168 # SKIP: 0
169 # XFAIL: 0
170 ${red}# FAIL: 1${std}
171 # XPASS: 0
172 # ERROR: 0
173 $failure_footer
176 # 1 xpass.
177 { echo 1..1 && echo 'ok # TODO'; } > all.test
178 do_check --fail <<END
179 $failure_header
180 ${brg}# TOTAL: 1${std}
181 # PASS: 0
182 # SKIP: 0
183 # XFAIL: 0
184 # FAIL: 0
185 ${red}# XPASS: 1${std}
186 # ERROR: 0
187 $failure_footer
190 # 1 hard error.
191 { echo 1..1 && echo 'Bail out!'; } > all.test
192 do_check --fail <<END
193 $failure_header
194 ${brg}# TOTAL: 1${std}
195 # PASS: 0
196 # SKIP: 0
197 # XFAIL: 0
198 # FAIL: 0
199 # XPASS: 0
200 ${mgn}# ERROR: 1${std}
201 $failure_footer
204 # 3 non-failing results.
205 cat > all.test <<END
206 1..3
208 not ok # TODO
209 ok # SKIP
211 do_check --pass <<END
212 $success_header
213 ${brg}# TOTAL: 3${std}
214 ${grn}# PASS: 1${std}
215 ${blu}# SKIP: 1${std}
216 ${lgn}# XFAIL: 1${std}
217 # FAIL: 0
218 # XPASS: 0
219 # ERROR: 0
220 $success_footer
223 # 1 pass, 1 skip, 1 fail.
224 cat > all.test <<END
225 1..3
227 ok # SKIP
228 not ok
230 do_check --fail <<END
231 $failure_header
232 ${brg}# TOTAL: 3${std}
233 ${grn}# PASS: 1${std}
234 ${blu}# SKIP: 1${std}
235 # XFAIL: 0
236 ${red}# FAIL: 1${std}
237 # XPASS: 0
238 # ERROR: 0
239 $failure_footer
242 # 1 pass, 1 xfail, 1 xpass.
243 cat > all.test <<END
244 1..3
246 ok # TODO
247 not ok # TODO
249 do_check --fail <<END
250 $failure_header
251 ${brg}# TOTAL: 3${std}
252 ${grn}# PASS: 1${std}
253 # SKIP: 0
254 ${lgn}# XFAIL: 1${std}
255 # FAIL: 0
256 ${red}# XPASS: 1${std}
257 # ERROR: 0
258 $failure_footer
261 # 1 skip, 1 xfail, 1 error.
262 cat > all.test <<END
263 1..3
264 ok # SKIP
265 not ok # TODO
266 Bail out!
268 do_check --fail <<END
269 $failure_header
270 ${brg}# TOTAL: 3${std}
271 # PASS: 0
272 ${blu}# SKIP: 1${std}
273 ${lgn}# XFAIL: 1${std}
274 # FAIL: 0
275 # XPASS: 0
276 ${mgn}# ERROR: 1${std}
277 $failure_footer
280 # 1 of each kind
281 cat > all.test <<END
282 1..6
284 not ok
285 ok # TODO
286 not ok # TODO
287 ok # SKIP
288 Bail out!
290 do_check --fail <<END
291 $failure_header
292 ${brg}# TOTAL: 6${std}
293 ${grn}# PASS: 1${std}
294 ${blu}# SKIP: 1${std}
295 ${lgn}# XFAIL: 1${std}
296 ${red}# FAIL: 1${std}
297 ${red}# XPASS: 1${std}
298 ${mgn}# ERROR: 1${std}
299 $failure_footer
302 # Prepare some common data for later.
303 for i in 0 1 2 3 4 5 6 7 8 9; do
304 for j in 0 1 2 3 4 5 6 7 8 9; do
305 echo "ok"
306 echo "not ok # TODO"
307 echo "ok # SKIP"
308 done
309 done > tap
311 # Lots of non-failures (300 per kind).
312 (cat tap && cat tap && cat tap) > all.test
313 test $(wc -l <all.test) -eq 900 || exit 99 # Sanity check.
314 echo 1..900 >> all.test # Test plan.
315 do_check --pass <<END
316 $success_header
317 ${brg}# TOTAL: 900${std}
318 ${grn}# PASS: 300${std}
319 ${blu}# SKIP: 300${std}
320 ${lgn}# XFAIL: 300${std}
321 # FAIL: 0
322 # XPASS: 0
323 # ERROR: 0
324 $success_footer
327 # 1 failure and lots of non-failures means failure.
328 (cat tap && echo "not ok" && cat tap) > all.test
329 test $(wc -l <all.test) -eq 601 || exit 99 # Sanity check.
330 echo 1..601 >> all.test # Test plan.
331 do_check --fail <<END
332 $failure_header
333 ${brg}# TOTAL: 601${std}
334 ${grn}# PASS: 200${std}
335 ${blu}# SKIP: 200${std}
336 ${lgn}# XFAIL: 200${std}
337 ${red}# FAIL: 1${std}
338 # XPASS: 0
339 # ERROR: 0
340 $failure_footer
343 # 1 error and lots of non-failures means failure.
344 (cat tap && sed 30q tap && echo 'Bail out!') > all.test
345 test $(wc -l <all.test) -eq 331 || exit 99 # Sanity check.
346 echo 1..331 >> all.test # Test plan.
347 do_check --fail <<END
348 $failure_header
349 ${brg}# TOTAL: 331${std}
350 ${grn}# PASS: 110${std}
351 ${blu}# SKIP: 110${std}
352 ${lgn}# XFAIL: 110${std}
353 # FAIL: 0
354 # XPASS: 0
355 ${mgn}# ERROR: 1${std}
356 $failure_footer