tests: avoid a spurious failure on MSYS
[platform/upstream/automake.git] / t / auxdir-autodetect.sh
1 #! /bin/sh
2 # Copyright (C) 2010-2013 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 # Make sure that, if AC_CONFIG_AUX_DIR is not specified, Automake tries
18 # to use '.', '..' and '../..', in precisely that order.
19
20 . test-init.sh
21
22 nil=__no_such_program
23
24 unset NONESUCH
25
26 cat >>configure.ac << END
27 AM_MISSING_PROG([NONESUCH],[$nil])
28 AC_OUTPUT
29 END
30
31 mkdir d3
32 mkdir d3/d2
33 mkdir d3/d2/d1
34 mkdir d3/d2/d1/d0
35
36 echo 'echo %%d3%% $*' > d3/missing
37 chmod +x d3/missing
38 echo 'echo %%d2%% $*' > d3/d2/missing
39 chmod +x d3/d2/missing
40 echo 'echo %%d1%% $*' > d3/d2/d1/missing
41 chmod +x d3/d2/d1/missing
42 echo 'echo %%d0%% $*' > d3/d2/d1/d0/missing
43 chmod +x d3/d2/d1/d0/missing
44
45 mv configure.ac d3/d2/d1/d0/
46
47 cd d3/d2/d1/d0
48
49 cat > Makefile.am << 'EOF'
50 .PHONY: test
51 test:
52         $(NONESUCH) >$(out)
53 EOF
54
55 $ACLOCAL
56 $AUTOCONF
57
58 # ------------------------------------------- #
59 :  We must end up with AC_CONFIG_AUX_DIR = .  #
60 # ------------------------------------------- #
61
62 : > install-sh
63 $AUTOMAKE
64 ./configure
65 out=out0 $MAKE test
66 cat out0
67 grep "%%d0%%.*$nil" out0
68 grep '%%d[123]' out0 && exit 1
69
70 rm -f missing install-sh
71
72 # -------------------------------------------- #
73 :  We must end up with AC_CONFIG_AUX_DIR = ..  #
74 # -------------------------------------------- #
75
76 # Automake finds 'install-sh' in '.', so it assumes that auxdir is '.';
77 # but it won't find 'missing' in '.', so it will fail.
78 : > install-sh
79 AUTOMAKE_fails
80 grep 'required file.*[^.]\./missing.*not found' stderr
81 rm -f install-sh
82
83 # Now things should work.
84 : > ../install-sh
85 $AUTOMAKE
86 ./configure
87 out=out1 $MAKE test
88 cat out1
89 grep "%%d1%%.*$nil" out1
90 grep '%%d[023]' out1 && exit 1
91
92 rm -f ../missing ../install-sh
93
94 # ----------------------------------------------- #
95 :  We must end up with AC_CONFIG_AUX_DIR = ../..  #
96 # ----------------------------------------------- #
97
98 # Automake finds 'install-sh' in '.', so it assumes that auxdir is '.';
99 # but it won't find 'missing' in '.', so it will fail.
100 : > install-sh
101 AUTOMAKE_fails
102 grep 'required file.*[^.]\./missing.*not found' stderr
103 rm -f install-sh
104
105 # Automake finds 'install-sh' in '..', so it assumes that auxdir is '..';
106 # but it won't find 'missing' in '.', so it will fail.
107 : > ../install-sh
108 AUTOMAKE_fails
109 grep 'required file.*[^.]\.\./missing.*not found' stderr
110 rm -f ../install-sh
111
112 # Now things should work.
113 : > ../../install-sh
114 $AUTOMAKE
115 ./configure
116 out=out2 $MAKE test
117 cat out2
118 grep "%%d2%%.*$nil" out2
119 grep '%%d[013]' out2 && exit 1
120
121 rm -f ../../missing ../../install-sh
122
123 # --------------------------------------------------------- #
124 :  AC_CONFIG_AUX_DIR will not be found: Automake must fail  #
125 # --------------------------------------------------------- #
126
127 AUTOMAKE_fails
128 grep 'required file.*missing.*not found' stderr
129
130 :