2 # Copyright (C) 2011-2013 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 # TAP support: more unusual forms for valid TAP input.
18 # See also related test 'tap-fancy.sh'.
25 # From manpage Test::Harness::TAP(3):
27 # Lines written to standard output matching /^(not )?ok\b/ must be
28 # interpreted as test lines. All other lines must not be considered
31 # Unfortunately, the exact format of TODO and SKIP directives is not as
32 # clearly described in that manpage; but a simple reverse-engineering of
33 # the prove(1) utility shows that it is probably given by the perl regex
34 # /#\s*(TODO|SKIP)\b/.
37 # To avoid problems with backslashes in echo arguments.
38 xecho () { printf '%s\n' "$*"; }
40 # There are 34 values for $str ...
77 # ... each of them add 1 pass, 1 fail, ...
80 # ... and (generally) 4 skips, 4 xfails, and 4 xpasses ...
82 'result="ok" directive=SKIP' \
83 'result="not ok" directive=TODO' \
84 'result="ok" directive=TODO' \
87 xecho "${result}# ${directive}${str}"
88 # ... but 6 skips, 6 xpasses and 6 xfails are to be removed, since
89 # they might not work with $str = '#' or $str = '\' ...
90 if test x"$str" != x'#' && test x"$str" != x'\'; then
91 xecho "${result}${str}#${directive}"
92 xecho "${result}${str}# ${tab}${tab} ${directive}"
93 xecho "${result}${str}#${directive}${str}"
98 # Sanity check against a previous use of unportable usages of backslashes
99 # with the "echo" builtin.
100 if grep '[^\\]\\#' all.test; then
101 framework_failure_ "writing backslashes in all.test"
104 # ... so that we finally have:
107 xfail=130 # = 4 * 34 - 6
108 xpass=130 # = 4 * 34 - 6
109 skip=130 # = 4 * 34 - 6
111 total=$(($pass + $fail + $xfail + $xpass + $skip))
113 # Even nastier! But accordingly to the specifics, it should still work.
114 for result in 'ok' 'not ok'; do
115 echo "${result}{[(<#${tab}TODO>)]}" >> all.test
117 echo "ok{[(<#${tab}SKIP>)]}" >> all.test
119 # We have to update some test counts.
120 xfail=$(($xfail + 1))
121 xpass=$(($xpass + 1))
123 total=$(($total + 3))
125 # And add the test plan!
126 echo 1..$total >> all.test
128 $MAKE check >stdout && { cat stdout; exit 1; }
131 $EGREP '^(PASS|FAIL|SKIP).*#.*TODO' stdout && exit 1
132 $EGREP '^X?(PASS|FAIL).*#.*SKIP' stdout && exit 1
134 count_test_results total=$total pass=$pass fail=$fail skip=$skip \
135 xpass=$xpass xfail=$xfail error=$error