tests: work around strangeness in MSYS
[automake.git] / tests / tap-fancy2.test
blobb661146c78f24943afa546cc1f00df7a5b0ad5a4
1 #! /bin/sh
2 # Copyright (C) 2011 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 # TAP support: more unusual forms for valid TAP input.
18 # See also related test 'tap-fancy.test'.
20 am_parallel_tests=yes
21 . ./defs || Exit 1
23 . "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
26 # From manpage Test::Harness::TAP(3):
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.''
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/.
38 # To avoid problems with backslashes in echo arguments.
39 xecho () { printf '%s\n' "$*"; }
41 # There are 34 values for $str ...
42 for str in \
43 \' \
44 '"' \
45 '`' \
46 '#' \
47 '$' \
48 '!' \
49 '\' \
50 '/' \
51 '&' \
52 '%' \
53 '(' \
54 ')' \
55 '|' \
56 '^' \
57 '~' \
58 '?' \
59 '*' \
60 '+' \
61 '-' \
62 ',' \
63 ':' \
64 ';' \
65 '=' \
66 '<' \
67 '>' \
68 '@' \
69 '[' \
70 ']' \
71 '{' \
72 '}' \
73 '\\' \
74 '...' \
75 '?[a-zA-Z0-9]*' \
76 '*.*' \
77 ; do
78 # ... each of them add 1 pass, 1 fail, ...
79 xecho "ok${str}"
80 xecho "not ok${str}"
81 # ... and (generally) 4 skips, 4 xfails, and 4 xpasses ...
82 for settings in \
83 'result="ok" directive=SKIP' \
84 'result="not ok" directive=TODO' \
85 'result="ok" directive=TODO' \
86 ; do
87 eval "$settings"
88 xecho "${result}# ${directive}${str}"
89 # ... but 6 skips, 6 xpasses and 6 xfails are to be removed, since
90 # they might not work with $str = '#' or $str = '\' ...
91 if test x"$str" != x'#' && test x"$str" != x'\'; then
92 xecho "${result}${str}#${directive}"
93 xecho "${result}${str}# ${tab}${tab} ${directive}"
94 xecho "${result}${str}#${directive}${str}"
96 done
97 done > all.test
99 # Sanity check against a previous use of unportable usages of backslashes
100 # with the "echo" builtin.
101 if grep '[^\\]\\#' all.test; then
102 framework_failure_ "writing backslashes in all.test"
105 # ... so that we finally have:
106 pass=34
107 fail=34
108 xfail=130 # = 4 * 34 - 6
109 xpass=130 # = 4 * 34 - 6
110 skip=130 # = 4 * 34 - 6
111 error=0
112 total=`expr $pass + $fail + $xfail + $xpass + $skip`
114 # Even nastier! But accordingly to the specifics, it should still work.
115 for result in 'ok' 'not ok'; do
116 echo "${result}{[(<#${tab}TODO>)]}" >> all.test
117 done
118 echo "ok{[(<#${tab}SKIP>)]}" >> all.test
120 # We have to update some test counts.
121 xfail=`expr $xfail + 1`
122 xpass=`expr $xpass + 1`
123 skip=`expr $skip + 1`
124 total=`expr $total + 3`
126 # And add the test plan!
127 echo 1..$total >> all.test
129 $MAKE check >stdout && { cat stdout; Exit 1; }
130 cat stdout
132 $EGREP '^(PASS|FAIL|SKIP).*#.*TODO' stdout && Exit 1
133 $EGREP '^X?(PASS|FAIL).*#.*SKIP' stdout && Exit 1
135 count_test_results total=$total pass=$pass fail=$fail skip=$skip \
136 xpass=$xpass xfail=$xfail error=$error