tests: use more POSIX shell features our test scripts
[platform/upstream/automake.git] / t / ac-output-old.tap
1 #!/bin/sh
2 # Copyright (C) 1996-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 # Test for various older bugs related to quoting, escaping and
18 # line breaking in the use of AC_OUTPUT.  Synthesised by a bunch
19 # of older tests (referenced below).
20
21 . ./defs || Exit 1
22
23 plan_ 22
24
25 rm -f configure.ac depcomp # Not required.
26
27 AUTOMAKE="$AUTOMAKE -Wno-obsolete"
28
29 # -----------------------------------------------------------------------
30
31 # Test for bug reported by François Pinard.
32 # If \ is in AC_OUTPUT, automake barfs.
33 # This was the old test 'acoutbs.test'.
34
35 # Also test for bug reported by David A. Swierczek.
36 # Another bug with \ in AC_OUTPUT (this time with whitespace).
37 # This was the old test 'acoutbs2.test'.
38
39 acoutbs_check ()
40 {
41   dir=acoutbs$1
42   mkdir $dir
43   cd $dir
44   cat > configure.ac
45   touch Makefile.am zot.in
46   command_ok_ "aclocal groks '\\' in AC_OUTPUT ($dir)" $ACLOCAL
47   command_ok_ "automake groks '\\' in AC_OUTPUT ($dir)" $AUTOMAKE
48   command_ok_ "autoconf groks '\\' in AC_OUTPUT ($dir)" $AUTOCONF
49   command_ok_ "can ./configure in $dir" ./configure
50   command_ok_ "zot created in $dir" test -f zot
51   ls -a > lst || bailout_ "cannot get file listing in $dir"
52   command_ok_ "'\\' not leaked in filenames in $dir" not grep '\\' lst
53   cd ..
54 }
55
56 acoutbs_check 1 << 'END'
57 AC_INIT
58 AM_INIT_AUTOMAKE(nonesuch, nonesuch)
59 AC_OUTPUT(Makefile \
60 zot)
61 END
62
63 acoutbs_check 2 << 'END'
64 AC_INIT
65 AM_INIT_AUTOMAKE(nonesuch, nonesuch)
66 AC_ARG_PROGRAM
67 AC_PROG_INSTALL
68 AC_PROG_MAKE_SET
69 AC_OUTPUT(\
70    Makefile \
71    zot
72 )
73 END
74
75 # -----------------------------------------------------------------------
76
77 # Test for bug reported by Jerome Santini.
78 # If I put this line in my configure.ac:
79 #  AC_OUTPUT(Makefile src/Makefile tests/Makefile, echo timestamp > stamp-h)dnl
80 # automake is not happy:
81 #  [ ... ]
82 # This was the old test 'acoutnoq.test'.
83
84 mkdir acoutnoq
85 cd acoutnoq
86
87 cat > configure.ac << 'END'
88 AC_INIT
89 AM_INIT_AUTOMAKE(nonesuch, nonesuch)
90 AC_OUTPUT(Makefile, [true])
91 END
92
93 : > Makefile.am
94
95 command_ok_ "aclocal and quoted AC_OUTPUT second argument" $ACLOCAL
96 command_ok_ "automake and quoted AC_OUTPUT second argument" $AUTOMAKE
97
98 cd ..
99
100 # -----------------------------------------------------------------------
101
102 # Test for bug when AC_OUTPUT has 2 args on the same line, eg:
103 #   AC_OUTPUT([Makefile automake tests/Makefile],[chmod +x automake])
104 # This was the old test 'acoutpt.test'.
105
106 mkdir acoutpt
107 cd acoutpt
108
109 cat > configure.ac << 'END'
110 AC_INIT
111 AM_INIT_AUTOMAKE(nonesuch, nonesuch)
112 AC_OUTPUT([Makefile], [true])
113 END
114
115 : > Makefile.am
116
117 command_ok_ "aclocal and two AC_OUTPUT arguments on same line" $ACLOCAL
118 command_ok_ "automake and two AC_OUTPUT arguments on same line" $AUTOMAKE
119
120 cd ..
121
122 # -----------------------------------------------------------------------
123
124 # Test for bug reported by Eric Magnien.
125 # This was the old test 'acoutpt2.test'.
126
127 mkdir acoutpt2
128 cd acoutpt2
129
130 # Name of the current "subtest".
131 cur=acoutput2
132
133 cat > configure.ac <<END
134 AC_INIT([$cur], [1.0])
135 AM_INIT_AUTOMAKE
136 AC_OUTPUT([subdir/Makefile subdir/foo Makefile foo], [true])
137 END
138
139 mkdir subdir
140
141 : > Makefile.am
142 : > subdir/Makefile.am
143 : > foo.in
144 : > subdir/foo.in
145
146 command_ok_ "aclocal and AC_OUTPUT ($cur)" $ACLOCAL
147 command_ok_ "automake and AC_OUTPUT ($cur)" $AUTOMAKE
148 command_ok_ "foo.in mentioned two times in Makefile.in ($cur)" \
149              test $($FGREP -c 'foo.in' Makefile.in) -eq 2
150
151 # This ought to work as well.
152 command_ok_ "'automake -a -f' and AC_OUTPUT ($cur)" \
153             $AUTOMAKE --add-missing --force-missing
154
155 cd ..
156
157 # -----------------------------------------------------------------------
158
159 # Test for bug reported by François Pinard.
160 # This was the old test 'acoutqnl.test'.
161
162 mkdir acoutqnl
163 cd acoutqnl
164
165 cat > configure.ac << 'END'
166 AC_INIT
167 AM_INIT_AUTOMAKE(nonesuch, nonesuch)
168 AC_OUTPUT([Makefile],
169 [echo zardoz has spoken])
170 END
171
172 : > Makefile.am
173
174 command_ok_ "aclocal and two AC_OUTPUT arguments on two lines" $ACLOCAL
175 command_ok_ "automake and two AC_OUTPUT arguments on two lines" $AUTOMAKE
176
177 cd ..
178
179 # -----------------------------------------------------------------------
180
181 # And we're done.
182 Exit 0