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)
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.
21 br='============================================================================'
25 *) fatal_ "invalid \$use_colors value '$use_colors'"
30 cat > configure.ac <<END
31 AC_INIT([GNU AutoTAP], [5.12], [bug-automake@gnu.org])
33 AC_CONFIG_FILES([Makefile])
37 cat > Makefile.am << 'END'
38 TEST_LOG_DRIVER = $(srcdir)/tap-driver
39 TEST_LOG_COMPILER = cat
43 # The following shell variables are influential for this function:
49 1,--pass) expect_failure=no;;
50 1,--fail) expect_failure=yes;;
51 *) fatal_ "invalid usage of 'do_check'";;
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"
64 $make_cmd check > stdout || st=$?
66 if test $expect_failure = yes; then
67 test $st -gt 0 || Exit 1
69 test $st -eq 0 || Exit 1
71 $PERL "$am_testauxdir"/extract-testsuite-summary.pl stdout >summary.got \
72 || fatal_ "cannot extract testsuite summary"
75 if test $use_colors = yes; then
76 # Use cmp, not diff, because the files might contain binary data.
81 $compare summary.exp summary.got || Exit 1
84 if test $use_colors = yes; then
92 echo AUTOMAKE_OPTIONS = color-tests >> Makefile.am
94 red= grn= lgn= blu= mgn= brg= std=
99 ${grn}Testsuite summary for GNU AutoTAP 5.12${std}
102 success_footer=${grn}${br}${std}
106 ${red}Testsuite summary for GNU AutoTAP 5.12${std}
111 ${red}See ./test-suite.log${std}
112 ${red}Please report to bug-automake@gnu.org${std}
117 $AUTOMAKE --add-missing
122 { echo 1..1 && echo ok; } > all.test
123 do_check --pass <<END
125 ${brg}# TOTAL: 1${std}
126 ${grn}# PASS: 1${std}
136 { echo 1..1 && echo 'ok # SKIP'; } > all.test
137 do_check --pass <<END
139 ${brg}# TOTAL: 1${std}
141 ${blu}# SKIP: 1${std}
150 { echo 1..1 && echo 'not ok # TODO'; } > all.test
151 do_check --pass <<END
153 ${brg}# TOTAL: 1${std}
156 ${lgn}# XFAIL: 1${std}
164 { echo 1..1 && echo not ok; } > all.test
165 do_check --fail <<END
167 ${brg}# TOTAL: 1${std}
171 ${red}# FAIL: 1${std}
178 { echo 1..1 && echo 'ok # TODO'; } > all.test
179 do_check --fail <<END
181 ${brg}# TOTAL: 1${std}
186 ${red}# XPASS: 1${std}
192 { echo 1..1 && echo 'Bail out!'; } > all.test
193 do_check --fail <<END
195 ${brg}# TOTAL: 1${std}
201 ${mgn}# ERROR: 1${std}
205 # 3 non-failing results.
212 do_check --pass <<END
214 ${brg}# TOTAL: 3${std}
215 ${grn}# PASS: 1${std}
216 ${blu}# SKIP: 1${std}
217 ${lgn}# XFAIL: 1${std}
224 # 1 pass, 1 skip, 1 fail.
231 do_check --fail <<END
233 ${brg}# TOTAL: 3${std}
234 ${grn}# PASS: 1${std}
235 ${blu}# SKIP: 1${std}
237 ${red}# FAIL: 1${std}
243 # 1 pass, 1 xfail, 1 xpass.
250 do_check --fail <<END
252 ${brg}# TOTAL: 3${std}
253 ${grn}# PASS: 1${std}
255 ${lgn}# XFAIL: 1${std}
257 ${red}# XPASS: 1${std}
262 # 1 skip, 1 xfail, 1 error.
269 do_check --fail <<END
271 ${brg}# TOTAL: 3${std}
273 ${blu}# SKIP: 1${std}
274 ${lgn}# XFAIL: 1${std}
277 ${mgn}# ERROR: 1${std}
291 do_check --fail <<END
293 ${brg}# TOTAL: 6${std}
294 ${grn}# PASS: 1${std}
295 ${blu}# SKIP: 1${std}
296 ${lgn}# XFAIL: 1${std}
297 ${red}# FAIL: 1${std}
298 ${red}# XPASS: 1${std}
299 ${mgn}# ERROR: 1${std}
303 # Prepare some common data for later.
304 for i in 0 1 2 3 4 5 6 7 8 9; do
305 for j in 0 1 2 3 4 5 6 7 8 9; do
312 # Lots of non-failures (300 per kind).
313 (cat tap && cat tap && cat tap) > all.test
314 test `wc -l <all.test` -eq 900 || Exit 99 # Sanity check.
315 echo 1..900 >> all.test # Test plan.
316 do_check --pass <<END
318 ${brg}# TOTAL: 900${std}
319 ${grn}# PASS: 300${std}
320 ${blu}# SKIP: 300${std}
321 ${lgn}# XFAIL: 300${std}
328 # 1 failure and lots of non-failures means failure.
329 (cat tap && echo "not ok" && cat tap) > all.test
330 test `wc -l <all.test` -eq 601 || Exit 99 # Sanity check.
331 echo 1..601 >> all.test # Test plan.
332 do_check --fail <<END
334 ${brg}# TOTAL: 601${std}
335 ${grn}# PASS: 200${std}
336 ${blu}# SKIP: 200${std}
337 ${lgn}# XFAIL: 200${std}
338 ${red}# FAIL: 1${std}
344 # 1 error and lots of non-failures means failure.
345 (cat tap && sed 30q tap && echo 'Bail out!') > all.test
346 test `wc -l <all.test` -eq 331 || Exit 99 # Sanity check.
347 echo 1..331 >> all.test # Test plan.
348 do_check --fail <<END
350 ${brg}# TOTAL: 331${std}
351 ${grn}# PASS: 110${std}
352 ${blu}# SKIP: 110${std}
353 ${lgn}# XFAIL: 110${std}
356 ${mgn}# ERROR: 1${std}