Merge branch master into maint after 1.12 release
[platform/upstream/automake.git] / t / tap-fancy.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: some unusual forms for valid TAP input.
18 # See also related test 'tap-fancy2.test'.
19
20 am_parallel_tests=yes
21 . ./defs || Exit 1
22
23 . "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
24
25 #
26 # From manpage Test::Harness::TAP(3):
27 #
28 # ``Lines written to standard output matching /^(not )?ok\b/ must be
29 #   interpreted as test lines. All other lines must not be considered
30 #   test output.''
31 #
32 # Unfortunately, the exact format of TODO and SKIP directives is not as
33 # clearly described in that manpage; but a simple reverse-engineering of
34 # the prove(1) utility shows that it is probably given by the perl regex
35 # /#\s*(TODO|SKIP)\b/.
36 #
37
38 cat > all.test <<END
39 1..21
40
41 ok? a question
42 not ok? a question
43
44 ok+plus
45 not ok+plus
46
47 ok-minus
48 not ok-minus
49
50 ok#55
51 not ok#55
52
53 ok${tab}  ${tab}9
54 ok ${tab}${tab}          10
55
56 not ok${tab}  ${tab}11
57 not ok ${tab}${tab}          12
58
59 ok# SKIP
60 ok${tab}#SKIP--who cares?
61 ok?#SKIP!
62 ok!#SKIP?
63
64 not ok# TODO
65 not ok${tab}#TODO--who cares?
66 not ok?#TODO!
67 not ok!#TODO?
68
69 ok~#TODO
70 END
71
72 $MAKE check >stdout && { cat stdout; Exit 1; }
73 cat stdout
74
75 count_test_results total=21 pass=6 fail=6 xfail=4 xpass=1 skip=4 error=0
76
77 #
78 # "Weird" characters support.
79 #
80
81 # The "#" character might cause confusion w.r.t. TAP directives (TODO,
82 # SKIP), so we don't attempt to use it.
83 weirdchars=\''"$!&()[]<>;^?*/@%=,.:'
84
85 cat > all.test <<END
86 1..6
87 ok $weirdchars
88 not ok $weirdchars
89 ok $weirdchars # TODO
90 not ok $weirdchars # TODO
91 ok $weirdchars # SKIP
92 Bail out! $weirdchars
93 END
94
95 $MAKE check >stdout && { cat stdout; Exit 1; }
96 cat stdout
97
98 count_test_results total=6 pass=1 fail=1 xfail=1 xpass=1 skip=1 error=1
99 $FGREP "PASS: all.test 1 $weirdchars" stdout
100 $FGREP "FAIL: all.test 2 $weirdchars" stdout
101 $FGREP "XPASS: all.test 3 $weirdchars" stdout
102 $FGREP "XFAIL: all.test 4 $weirdchars" stdout
103 $FGREP "SKIP: all.test 5 $weirdchars" stdout
104 $FGREP "ERROR: all.test - Bail out! $weirdchars" stdout
105
106 #
107 # Trailing backslashes does not confuse the parser.
108 #
109
110 bs='\'
111
112 cat > all.test <<END
113 1..6
114 ok $bs
115 not ok $bs
116 ok # TODO $bs
117 not ok # TODO $bs
118 ok # SKIP $bs
119 Bail out! $bs
120 END
121
122 $MAKE check >stdout && { cat stdout; Exit 1; }
123 cat stdout
124
125 count_test_results total=6 pass=1 fail=1 xfail=1 xpass=1 skip=1 error=1
126 grep '^PASS: all\.test 1 \\$' stdout
127 grep '^FAIL: all\.test 2 \\$' stdout
128 grep '^XPASS: all\.test 3 # TODO \\$' stdout
129 grep '^XFAIL: all\.test 4 # TODO \\$' stdout
130 grep '^SKIP: all\.test 5 # SKIP \\$' stdout
131 grep '^ERROR: all\.test - Bail out! \\$' stdout
132
133 :