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