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