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