doc: typos in test file.
[automake.git] / t / dejagnu-siteexp-extend.sh
blob9c670765461aeee53f57b3c97c980abbde808a06
1 #! /bin/sh
2 # Copyright (C) 2011-2024 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 <https://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_CONFIG_FILES([testsuite/Makefile])
37 AC_OUTPUT
38 END
40 cat > Makefile.am << 'END'
41 SUBDIRS = testsuite
42 END
44 mkdir testsuite
46 cat > testsuite/Makefile.am << 'END'
47 AUTOMAKE_OPTIONS = dejagnu
48 DEJATOOL = tool
50 EXTRA_DIST = tool.test/tool.exp
52 EXTRA_DEJAGNU_SITE_CONFIG = foo.exp
53 EXTRA_DIST += foo.exp
54 END
56 echo 'set foo "/foo/"' > testsuite/foo.exp
58 mkdir testsuite/tool.test
59 write_check_for foo > testsuite/tool.test/tool.exp
60 cat testsuite/tool.test/tool.exp
62 $ACLOCAL
63 $AUTOCONF
64 $AUTOMAKE --add-missing
66 ./configure
68 $MAKE check
69 cat testsuite/foo.exp
70 cat testsuite/site.exp
71 grep 'PASS: test_foo' testsuite/tool.sum
73 write_check_for bar >> testsuite/tool.test/tool.exp
74 write_check_for baz >> testsuite/tool.test/tool.exp
75 cat testsuite/tool.test/tool.exp
77 # Ensure that foo.exp will be newer than site.exp, which will
78 # thus have to be remade.
79 $sleep
80 # With this, below we'll also check that settings in files coming later in
81 # $(EXTRA_DEJAGNU_SITE_CONFIG) override those in files coming earlier.
82 cat >> testsuite/foo.exp <<'END'
83 set bar "/foo/"
84 set baz "/foo/"
85 set qux "/foo/"
86 END
88 $MAKE check && { cat testsuite/site.exp; exit 1; }
89 grep 'PASS: test_foo' testsuite/tool.sum
90 grep 'FAIL: test_bar' testsuite/tool.sum
91 grep 'FAIL: test_baz' testsuite/tool.sum
93 cat >> testsuite/Makefile.am << 'END'
94 EXTRA_DEJAGNU_SITE_CONFIG += bar bar.dir/bar
95 EXTRA_DIST += bar
96 DISTCLEANFILES = bar.dir/bar
97 bar.dir/bar:
98 test -d bar.dir || mkdir bar.dir
99 echo 'set baz "/baz/"' > $@
102 echo 'set bar "/bar/"' > testsuite/bar
103 # This will allow us to check one more time that settings in files
104 # coming later in $(EXTRA_DEJAGNU_SITE_CONFIG) override those in
105 # files coming earlier.
106 echo 'set baz "/xyz/"' >> testsuite/bar
108 # Ensure that the Makefile will be newer than site.exp, which will
109 # thus have to be remade.
110 $sleep
111 $AUTOMAKE testsuite/Makefile
112 ./config.status testsuite/Makefile
114 $MAKE check || { cat testsuite/site.exp; exit 1; }
115 cat testsuite/site.exp
116 cat testsuite/bar.dir/bar
117 $FGREP '/bar/' testsuite/site.exp
118 $FGREP '/baz/' testsuite/site.exp
119 grep 'PASS: test_foo' testsuite/tool.sum
120 grep 'PASS: test_bar' testsuite/tool.sum
121 grep 'PASS: test_baz' testsuite/tool.sum
123 # Check that the features we're testing behave well in VPATH builds.
124 $MAKE distcheck
126 # Check that the user can edit the site.exp file, and that his edits
127 # are retained.
128 write_check_for zardoz >> testsuite/tool.test/tool.exp
129 cat testsuite/tool.test/tool.exp
130 echo 'set zardoz "/zardoz/"' >> testsuite/site.exp
132 $MAKE check
133 cat testsuite/site.exp
134 grep 'PASS: test_zardoz' testsuite/tool.sum
136 cat >> testsuite/Makefile.am << 'END'
137 EXTRA_DEJAGNU_SITE_CONFIG += quux.exp
138 quux.exp:
139 echo 'set zardoz "/quux/"' > $@
142 # Ensure that the Makefile will be newer than on site.exp, which will
143 # thus have to be remade.
144 $sleep
145 $AUTOMAKE testsuite/Makefile
146 ./config.status testsuite/Makefile
147 grep 'zardoz.*/quux/' testsuite/Makefile
149 (cd testsuite/ && $MAKE site.exp)
150 cat testsuite/site.exp
151 cat testsuite/quux.exp
152 grep 'zardoz.*/quux/' testsuite/site.exp
154 $MAKE check
155 grep 'PASS: test_zardoz' testsuite/tool.sum
156 grep 'zardoz: /zardoz/' testsuite/tool.log
157 grep 'zardoz.*quux' testsuite/tool.log && exit 1
159 # Check that files in $(EXTRA_DEJAGNU_SITE_CONFIG) are not distributed
160 # by default.
161 $MAKE distdir
162 ls -l $distdir
163 test ! -e $distdir/testsuite/bar.dir/bar
164 test ! -e $distdir/testsuite/quux.exp