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 # TAP support: more unusual forms for valid TAP input.
18 # See also related test 'tap-fancy.test'.
23 . "$am_testauxdir"/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
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 ...
78 # ... each of them add 1 pass, 1 fail, ...
81 # ... and (generally) 4 skips, 4 xfails, and 4 xpasses ...
83 'result="ok" directive=SKIP' \
84 'result="not ok" directive=TODO' \
85 'result="ok" directive=TODO' \
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}"
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:
108 xfail=130 # = 4 * 34 - 6
109 xpass=130 # = 4 * 34 - 6
110 skip=130 # = 4 * 34 - 6
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
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; }
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