aclocal: fix for more-than-once specified directories
[platform/upstream/automake.git] / t / make-dryrun.tap
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 $(am__make_dryrun) works as expected.
18
19 . test-init.sh
20
21 plan_ 14
22
23 if echo "all: ; @+printf %sbb%s aa cc" | $MAKE -n -f - | grep aabbcc; then
24   make_plus_silence () { return 0; }
25 else
26   make_plus_silence () { return 1; }
27 fi
28
29 mkdir sub
30
31 echo AC_OUTPUT >> configure.ac
32
33 cat > Makefile.am <<'END'
34 all:
35         : Dummy, nothing to do.
36 foo:
37         $(MAKE) all
38 notdry:
39         @echo ":: $$MAKEFLAGS ::"; : For debugging.
40         $(am__make_dryrun) && exit 1; exit 0
41 dry:
42         +@echo ":: $$MAKEFLAGS ::"; : For debugging.
43         +$(am__make_dryrun) || exit 1; echo ok > from-dry-mode
44 END
45
46 $ACLOCAL    || fatal_ "aclocal failed"
47 $AUTOCONF   || fatal_ "autoconf failed"
48 $AUTOMAKE   || fatal_ "automake failed"
49 ./configure || fatal_ "configure failed"
50
51 # ----------------------------------------------------------------------
52
53 check_no_dryrun ()
54 {
55   command_ok_ "dry-run ($cnt)" $MAKE notdry ${1+"$@"}
56   cnt=$(($cnt + 1))
57 }
58 cnt=1
59
60 check_no_dryrun
61
62 # Test against a known regression.  This was especially heinous, since
63 # make running in normal mode was sometimes mistaken for make running
64 # in dry mode.
65 check_no_dryrun TESTS="n1.test n2.test"
66 check_no_dryrun TESTS="n1 n2" AM_MAKEFLAGS="TESTS='n1 n2'"
67 check_no_dryrun TESTS="n1 n2" AM_MAKEFLAGS='TESTS="n1 n2"'
68 check_no_dryrun FOOFLAGS="-n -n -knf2 n --none -n"
69 check_no_dryrun MYFLAGS="-n --dryrun -n --dry-run -n"
70
71 # ----------------------------------------------------------------------
72
73 check_dryrun ()
74 {
75   r=ok directive=
76   case $1 in
77     -C) condition=$2 reason=$3; shift; shift; shift;;
78      *) condition=: reason=;;
79   esac
80   if $condition; then
81     $MAKE dry ${1+"$@"}   || r='not ok'
82     test -f from-dry-mode || r='not ok'
83     rm -f from-dry-mode   || fatal_ "cleaning up"
84   else
85     directive=SKIP
86   fi
87   result_ "$r" -D "$directive" -r "$reason" "not dry-run ($cnt)"
88   unset r directive reason
89   cnt=$(($cnt + 1))
90 }
91 cnt=1
92
93 check_dryrun -C make_plus_silence 'recipe prefix "+" unsupported' -n
94 check_dryrun -C using_gmake "\$MAKE is not GNU make" --dry-run -k
95
96 # ----------------------------------------------------------------------
97
98 # Test for when shell metacharacters or backslashes are in $(MAKEFLAGS).
99
100 check_metachars ()
101 {
102   r=ok
103   $MAKE notdry ${1+"$@"} || r='not ok'
104   if test -f bad; then
105     r='not ok'
106   else
107     rm -f bad || fatal_ "cleaning up"
108   fi
109   result_ "$r" "dry-run, with shell metachars ($cnt)"
110   unset r
111   cnt=$(($cnt + 1))
112 }
113 cnt=1
114
115 check_metachars MYFLAGS="-n \"n\" '-n' --none -n"
116 check_metachars MYFLAGS='-knf2\ n\ \\n'
117 check_metachars MYFLAGS="(&) | ; \" \` '"
118 check_metachars MYFLAGS=" ' # ' "
119 check_metachars MYFLAGS='$(foo)'
120 check_metachars MYFLAGS='`touch bad`'
121
122 # ----------------------------------------------------------------------
123
124 :