automake: do not emit rule with two dependents
[automake.git] / t / dejagnu-siteexp-extend.sh
blob4a8daeca7bf4ad060d1d2029dea1d3fd506e7ac1
1 #! /bin/sh
2 # Copyright (C) 2011-2015 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 # Check that the developer can extend the site.exp generated by the
18 # automake-generated Makefile.
20 required=runtest
21 . test-init.sh
23 write_check_for ()
25 echo "send_user \"$1: \$$1\\n\""
26 unindent << END
27 if { \$$1 == "/$1/" } {
28 pass "test_$1"
29 } else {
30 fail "test_$1"
32 END
35 cat >> configure.ac << 'END'
36 AC_OUTPUT
37 END
39 cat > Makefile.am << 'END'
40 AUTOMAKE_OPTIONS = dejagnu
41 DEJATOOL = tool
43 EXTRA_DIST = tool.test/tool.exp
45 EXTRA_DEJAGNU_SITE_CONFIG = foo.exp
46 EXTRA_DIST += foo.exp
47 END
49 echo 'set foo "/foo/"' > foo.exp
51 mkdir tool.test
52 write_check_for foo > tool.test/tool.exp
53 cat tool.test/tool.exp
55 $ACLOCAL
56 $AUTOCONF
57 $AUTOMAKE --add-missing
59 ./configure
61 $MAKE check
62 cat foo.exp
63 cat site.exp
64 grep 'PASS: test_foo' tool.sum
66 write_check_for bar >> tool.test/tool.exp
67 write_check_for baz >> tool.test/tool.exp
68 cat tool.test/tool.exp
70 # Ensure that foo.exp will be newer than site.exp, which will
71 # thus have to be remade.
72 $sleep
73 # With this, below we'll also check that settings in files coming later in
74 # $(EXTRA_DEJAGNU_SITE_CONFIG) override those in files coming earlier.
75 cat >> foo.exp <<'END'
76 set bar "/foo/"
77 set baz "/foo/"
78 set qux "/foo/"
79 END
81 $MAKE check && { cat site.exp; exit 1; }
82 grep 'PASS: test_foo' tool.sum
83 grep 'FAIL: test_bar' tool.sum
84 grep 'FAIL: test_baz' tool.sum
86 cat >> Makefile.am << 'END'
87 EXTRA_DEJAGNU_SITE_CONFIG += bar bar.dir/bar
88 EXTRA_DIST += bar
89 DISTCLEANFILES = bar.dir/bar
90 bar.dir/bar:
91 test -d bar.dir || mkdir bar.dir
92 echo 'set baz "/baz/"' > $@
93 END
95 echo 'set bar "/bar/"' > bar
96 # This will allow us to check one more time that settings in files
97 # coming later in $(EXTRA_DEJAGNU_SITE_CONFIG) override those in
98 # files coming earlier.
99 echo 'set baz "/xyz/"' >> bar
101 # Ensure that the Makefile will be newer than site.exp, which will
102 # thus have to be remade.
103 $sleep
104 $AUTOMAKE Makefile
105 ./config.status Makefile
107 $MAKE check || { cat site.exp; exit 1; }
108 cat site.exp
109 cat bar.dir/bar
110 $FGREP '/bar/' site.exp
111 $FGREP '/baz/' site.exp
112 grep 'PASS: test_foo' tool.sum
113 grep 'PASS: test_bar' tool.sum
114 grep 'PASS: test_baz' tool.sum
116 # Check that the features we're testing behave well in VPATH builds.
117 $MAKE distcheck
119 # Check that the user can edit the site.exp file, and that his edits
120 # are retained.
121 write_check_for zardoz >> tool.test/tool.exp
122 cat tool.test/tool.exp
123 echo 'set zardoz "/zardoz/"' >> site.exp
125 $MAKE check
126 cat site.exp
127 grep 'PASS: test_zardoz' tool.sum
129 cat >> Makefile.am << 'END'
130 EXTRA_DEJAGNU_SITE_CONFIG += quux.exp
131 quux.exp:
132 echo 'set zardoz "/quux/"' > $@
135 # Ensure that the Makefile will be newer than on site.exp, which will
136 # thus have to be remade.
137 $sleep
138 $AUTOMAKE Makefile
139 ./config.status Makefile
140 grep 'zardoz.*/quux/' Makefile
142 $MAKE site.exp
143 cat site.exp
144 cat quux.exp
145 grep 'zardoz.*/quux/' site.exp
147 $MAKE check
148 grep 'PASS: test_zardoz' tool.sum
149 grep 'zardoz: /zardoz/' tool.log
150 grep 'zardoz.*quux' tool.log && exit 1
152 # Check that files in $(EXTRA_DEJAGNU_SITE_CONFIG) are not distributed
153 # by default.
154 $MAKE distdir
155 ls -l $distdir
156 test ! -e $distdir/bar.dir/bar
157 test ! -e $distdir/quux.exp