tests: expose automake bug#14560
[platform/upstream/automake.git] / t / recurs-user-keep-going.sh
1 #! /bin/sh
2 # Copyright (C) 2012-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 # Check that user recursion works with "make -k".
18
19 . test-init.sh
20
21 cat >> configure.ac <<'END'
22 AM_EXTRA_RECURSIVE_TARGETS([foo])
23 AC_CONFIG_FILES([
24     sub1/Makefile
25     sub1/subsub1/Makefile
26     sub2/Makefile
27     sub2/subsub2/Makefile
28     sub3/Makefile
29 ])
30 FAIL='@echo "FAIL $@ in `pwd`"; exit 1'
31 PASS='@echo "PASS $@ in `pwd`"; : > foo'
32 AC_SUBST([FAIL])
33 AC_SUBST([PASS])
34 AC_OUTPUT
35 END
36
37 mkdir sub1 sub1/subsub1 sub2 sub2/subsub2 sub3
38
39 cat > Makefile.am <<'END'
40 SUBDIRS = sub1 . sub2 sub3
41 foo-local:; @FAIL@
42 END
43
44 cat > sub1/Makefile.am <<'END'
45 SUBDIRS = subsub1
46 foo-local:; @PASS@
47 END
48
49 cat > sub2/Makefile.am <<'END'
50 SUBDIRS = subsub2
51 foo-local:; @FAIL@
52 END
53
54 echo 'foo-local:; @FAIL@' > sub1/subsub1/Makefile.am
55 echo 'foo-local:; @PASS@' > sub2/subsub2/Makefile.am
56 echo 'foo-local:; @PASS@' > sub3/Makefile.am
57
58 $ACLOCAL
59 $AUTOCONF
60 $AUTOMAKE
61
62 ./configure
63
64 cat > exp <<END
65 ./sub1/foo
66 ./sub2/subsub2/foo
67 ./sub3/foo
68 END
69
70 as_expected ()
71 {
72   find . -name foo > t || { cat t; exit 1; }
73   LC_ALL=C sort t > got
74   cat exp
75   cat got
76   diff exp got
77 }
78
79 # Without "-k", we fail in 'sub1/subsub1', and do nothing else.
80 # So, no 'foo' file gets created.
81 $MAKE foo && exit 1
82 find . -name foo | grep . && exit 1
83
84 if using_gmake; then
85   $MAKE -k foo && exit 1
86   as_expected
87   $MAKE --keep-going foo && exit 1
88   as_expected
89 else
90   # Don't trust the exit status of 'make -k' for non-GNU makes.
91   $MAKE -k foo || :
92   as_expected
93 fi
94
95 :