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
93 red= grn= lgn= blu= mgn= brg= std=
98 ${grn}Testsuite summary for GNU AutoTAP 5.12${std}
101 success_footer=${grn}${br}${std}
105 ${red}Testsuite summary for GNU AutoTAP 5.12${std}
110 ${red}See ./test-suite.log${std}
111 ${red}Please report to bug-automake@gnu.org${std}
116 $AUTOMAKE --add-missing
121 { echo 1..1 && echo ok; } > all.test
122 do_check --pass <<END
124 ${brg}# TOTAL: 1${std}
125 ${grn}# PASS: 1${std}
135 { echo 1..1 && echo 'ok # SKIP'; } > all.test
136 do_check --pass <<END
138 ${brg}# TOTAL: 1${std}
140 ${blu}# SKIP: 1${std}
149 { echo 1..1 && echo 'not ok # TODO'; } > all.test
150 do_check --pass <<END
152 ${brg}# TOTAL: 1${std}
155 ${lgn}# XFAIL: 1${std}
163 { echo 1..1 && echo not ok; } > all.test
164 do_check --fail <<END
166 ${brg}# TOTAL: 1${std}
170 ${red}# FAIL: 1${std}
177 { echo 1..1 && echo 'ok # TODO'; } > all.test
178 do_check --fail <<END
180 ${brg}# TOTAL: 1${std}
185 ${red}# XPASS: 1${std}
191 { echo 1..1 && echo 'Bail out!'; } > all.test
192 do_check --fail <<END
194 ${brg}# TOTAL: 1${std}
200 ${mgn}# ERROR: 1${std}
204 # 3 non-failing results.
211 do_check --pass <<END
213 ${brg}# TOTAL: 3${std}
214 ${grn}# PASS: 1${std}
215 ${blu}# SKIP: 1${std}
216 ${lgn}# XFAIL: 1${std}
223 # 1 pass, 1 skip, 1 fail.
230 do_check --fail <<END
232 ${brg}# TOTAL: 3${std}
233 ${grn}# PASS: 1${std}
234 ${blu}# SKIP: 1${std}
236 ${red}# FAIL: 1${std}
242 # 1 pass, 1 xfail, 1 xpass.
249 do_check --fail <<END
251 ${brg}# TOTAL: 3${std}
252 ${grn}# PASS: 1${std}
254 ${lgn}# XFAIL: 1${std}
256 ${red}# XPASS: 1${std}
261 # 1 skip, 1 xfail, 1 error.
268 do_check --fail <<END
270 ${brg}# TOTAL: 3${std}
272 ${blu}# SKIP: 1${std}
273 ${lgn}# XFAIL: 1${std}
276 ${mgn}# ERROR: 1${std}
290 do_check --fail <<END
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}
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
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
317 ${brg}# TOTAL: 900${std}
318 ${grn}# PASS: 300${std}
319 ${blu}# SKIP: 300${std}
320 ${lgn}# XFAIL: 300${std}
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
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}
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
349 ${brg}# TOTAL: 331${std}
350 ${grn}# PASS: 110${std}
351 ${blu}# SKIP: 110${std}
352 ${lgn}# XFAIL: 110${std}
355 ${mgn}# ERROR: 1${std}