Merge branch 'maint'
[platform/upstream/automake.git] / t / tap-todo-skip-whitespace.sh
1 #! /bin/sh
2 # Copyright (C) 2011-2012 Free Software Foundation, Inc.
3 #
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.
8 #
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.
13 #
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/>.
16
17 # TAP support:
18 #  - normalization of whitespace in console testsuite progress associated
19 #    with TODO and SKIP directives
20
21 am_parallel_tests=yes
22 . ./defs || Exit 1
23
24 . "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
25
26 cat > stub.tap <<END
27 1 # TODO
28 2 # TODO foo?
29 3 # TODO: bar!
30 4 aa # TODO
31 5 bb # TODO       fnord 5
32 6 cc # TODO:${tab}fnord 6
33 7 - x # TODO
34 8 - y # TODO fnord $tab  8
35 9 - z # TODO: fnord 9  $tab
36 10# TODO x0
37 11$tab# TODO x1
38 12 $tab$tab   # TODO x2
39 13 asd# TODO x3
40 14 sad$tab# TODO x4
41 15 das$tab$tab   # TODO x5
42 END
43
44 cat > stub.exp <<END
45 1 # TODO
46 2 # TODO foo?
47 3 # TODO: bar!
48 4 aa # TODO
49 5 bb # TODO fnord 5
50 6 cc # TODO:${tab}fnord 6
51 7 - x # TODO
52 8 - y # TODO fnord $tab  8
53 9 - z # TODO: fnord 9
54 10 # TODO x0
55 11 # TODO x1
56 12 # TODO x2
57 13 asd # TODO x3
58 14 sad # TODO x4
59 15 das # TODO x5
60 END
61
62 plan=1..15
63
64 my_make_check ()
65 {
66   xpass=0 xfail=0 skip=0
67   case $1 in
68     xpass|xfail|skip) eval $1=15;;
69     *) fatal_ "bad argument '$1' for my_make_check";;
70   esac
71   cat all.test
72   $MAKE check >stdout || : # Don't care about the exit status in this test.
73   cat stdout
74   count_test_results total=15 pass=0 fail=0 error=0 \
75                      xpass=$xpass xfail=$xfail skip=$skip
76   # Don't be too strict w.r.t. possible normalization of "TODO: foo" into
77   # "TODO : foo" (as is done by, e.g., the 'TAP::Parser' perl module).
78   LC_ALL=C grep '^[A-Z][A-Z]*:' stdout \
79     | sed -e 's/# TODO *:/# TODO:/' -e 's/# SKIP *:/# SKIP:/' > got
80   cat exp
81   cat got
82   diff exp got
83 }
84
85 # For "TODO" directives leading to XPASS results.
86 (echo $plan && sed -e 's/^/ok /' stub.tap) > all.test
87 sed -e 's/^/XPASS: all.test /' stub.exp > exp
88 my_make_check xpass
89
90 # For "TODO" directives leading to XFAIL results.
91 (echo $plan && sed -e 's/^/not ok /' stub.tap) > all.test
92 sed -e 's/^/XFAIL: all.test /' stub.exp > exp
93 my_make_check xfail
94
95 # For "SKIP" directives.
96 (echo $plan && sed -e 's/^/ok /' -e 's/TODO/SKIP/' stub.tap) > all.test
97 sed -e 's/TODO/SKIP/' -e 's/^/SKIP: all.test /' stub.exp > exp
98 my_make_check skip
99
100 :