Avoid leaking TEST_LOG_COMPILER in environment of test scripts.
[automake.git] / tests / dollarvar.test
blobbdc73abbad075d57a15a7e061f69561cf299f63c
1 #!/bin/sh
2 # Copyright (C) 2009 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)
7 # any later version.
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 # Test to make sure that -Wportability complains about recursive
18 # variable expansions and variables containing `$', `$(...)', or
19 # `${...}' in the name. We support recursive variable expansions using
20 # the latter two constructs for the `silent-rules' option, and they are
21 # rather widely supported in practice. OTOH variable definitions
22 # containing a `$' on the left hand side of an assignment are not
23 # portable in practice, even though POSIX allows them. :-/
25 . ./defs
27 set -e
29 cat >Makefile.am <<'EOF'
30 x = 1
31 foo$x = 1
32 bar$(x) = 1
33 baz${x} = 1
34 bla = $(foo$x)
35 bli = $(foo$(x))
36 blo = $(foo${x})
37 EOF
39 $ACLOCAL
40 AUTOMAKE_fails -Wportability
41 grep 'Makefile.am:2' stderr
42 grep 'Makefile.am:3' stderr
43 grep 'Makefile.am:4' stderr
44 grep 'Makefile.am:5' stderr
45 grep 'Makefile.am:6' stderr
46 grep 'Makefile.am:7' stderr
48 # On the other hand, if we allow `silent-rules' mode, then we need to
49 # allow recursive variable expansion, too.
51 # This should work with the AM_SILENT_RULES macro.
52 $sleep
53 echo 'AM_SILENT_RULES' >> configure.in
55 $ACLOCAL --force
56 AUTOMAKE_fails -Wportability
57 grep 'Makefile.am:2' stderr
58 grep 'Makefile.am:3' stderr
59 grep 'Makefile.am:4' stderr
60 grep 'Makefile.am:5' stderr
61 grep 'Makefile.am:6' stderr && Exit 1
62 grep 'Makefile.am:7' stderr && Exit 1