tests: expose automake bug#14560
[platform/upstream/automake.git] / t / tap-diagnostic-custom.sh
1 #! /bin/sh
2 # Copyright (C) 2011-2013 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 #  - option '--diagnostic-string' to customize the string introducing
19 #    TAP diagnostics
20
21 . test-init.sh
22
23 fetch_tap_driver
24
25 cat >> configure.ac <<END
26 AC_OUTPUT
27 END
28
29 cat > Makefile.am << 'END'
30 my_log_driver = $(srcdir)/tap-driver
31 my_log_compiler = cat
32 TEST_EXTENSIONS =
33 TESTS =
34 END
35
36 : > later.mk
37
38 # Quoting our comments below is an hack required to keep
39 # comments near the things they refer to.
40 i=0
41 for string in \
42 '## A letter' \
43     a \
44 '## A number' \
45     1023 \
46 '## A non-alphabetic character' \
47     @ \
48 '## Some metacharacters (we need to repeat the "$" for make)' \
49     '^>;&*"|$$' \
50 '## A whitespace character' \
51     " " \
52 '## A tab character' \
53     "$tab" \
54 '## A string with more whitespace' \
55     "  ${tab}a b${tab} c" \
56 '## Note the we do not have the empty string here.  We prefer to' \
57 '## leave its behaviour in this context undefined for the moment.'
58 do
59   case $string in '##'*) continue;; esac
60   i=$(($i + 1))
61   unindent >> Makefile.am << END
62     TEST_EXTENSIONS += .t$i
63     TESTS += foo$i.t$i
64     T${i}_LOG_COMPILER = \$(my_log_compiler)
65     T${i}_LOG_DRIVER = \$(my_log_driver)
66     AM_T${i}_LOG_DRIVER_FLAGS = \
67       --comments \
68       --diagnostic-string '$string'
69 END
70   unindent > foo$i.t$i <<END
71     1..1
72     ok 1
73     $string blah blah $i
74 END
75     echo "AM_T${i}_LOG_DRIVER_FLAGS = --no-comments" >> later.mk
76 done
77
78 $ACLOCAL
79 $AUTOCONF
80 $AUTOMAKE
81
82 ./configure
83
84 run_make -O check
85 count_test_results total=$i pass=$i fail=0 xpass=0 xfail=0 skip=0 error=0
86
87 cat later.mk >> Makefile
88 run_make -O check
89 $FGREP 'blah blah' stdout && exit 1
90
91 :