header-vars: recognize more make flags ('-k' in particular)
[platform/upstream/automake.git] / t / make-keepgoing.tap
1 #! /bin/sh
2 # Copyright (C) 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_keepgoing) works as expected.
18
19 . test-init.sh
20
21 plan_ 20
22
23 mkdir kool # Also used later.
24 if echo nil: | $MAKE -I kool -f -; then
25   make_supports_option_I () { return 0; }
26 else
27   make_supports_option_I () { return 1; }
28 fi
29
30 echo AC_OUTPUT >> configure.ac
31
32 cat > Makefile.am <<'END'
33 all:
34         @echo 'Default target $@ should not be called'>&2; exit 1;
35 k-y:
36         @echo ":: $$MAKEFLAGS ::" ;: For debugging.
37         $(am__make_keepgoing)
38 k-n:
39         @echo ":: $$MAKEFLAGS ::" ;: For debugging.
40         ! $(am__make_keepgoing)
41 END
42
43 check_make ()
44 {
45   r=ok msg= mode= condition=: directive= reason= skip_reason=
46   case $1 in
47     k-[yn]) mode=$1;;
48     *) fatal_ "check_run: invalid usage";;
49   esac
50   shift
51   while test $# -gt 0; do
52     case $1 in
53       -C) condition=$2 skip_reason=$3; shift; shift;;
54       -M) msg=$2; shift;;
55       -X) directive=TODO;;
56       --) shift; break;;
57        *) break;;
58     esac
59     shift
60   done
61   msg=${mode}${msg:+" [$msg]"}
62   if $condition; then
63     $MAKE "$mode" ${1+"$@"} || r='not ok'
64   else
65     directive=SKIP reason=$skip_reason
66   fi
67   result_ "$r" -D "$directive" -r "$reason" "$msg"
68   unset r msg mode condition directive reason skip_reason
69 }
70
71 # ----------------------------------------------------------------------
72
73 $ACLOCAL    || fatal_ "aclocal failed"
74 $AUTOCONF   || fatal_ "autoconf failed"
75 $AUTOMAKE   || fatal_ "automake failed"
76 ./configure || fatal_ "configure failed"
77
78 # ----------------------------------------------------------------------
79
80 check_make k-n
81
82 # Test against a possible regressions similar to those that affected
83 # detection of dry mode ("make -n").
84 check_make k-n TESTS="k.test k2.test"
85 check_make k-n TESTS="k1 k k2" AM_MAKEFLAGS="TESTS='k1 k2'"
86 check_make k-n TESTS="k1 k k2" AM_MAKEFLAGS='TESTS="k1 k k2"'
87 check_make k-n FOOFLAGS="-k -k -nkf2 k -ks --keep -k"
88 check_make k-n MYFLAGS="-k --keepgoing -k --keep-run -k"
89
90 # ----------------------------------------------------------------------
91
92 check_make k-y -k
93 check_make k-y -C using_gmake "\$MAKE is not GNU make" --keep-going
94
95 # ----------------------------------------------------------------------
96
97 # Related to automake bug#12554: the "k" in "kool" used to confound
98 # am__make_keepgoing into thinking the '-k' option had been passed.
99
100 pr='bug#12554'
101
102 check_make k-n -C make_supports_option_I "-I make option unsupported" \
103                -M "$pr" -I kool
104
105 check_make k-n -C using_gmake "\$MAKE is not GNU make" \
106                -M "$pr" -I kool --include keep-going
107
108 check_make k-y -C make_supports_option_I "-I make option unsupported" \
109                -M "$pr" -I kool -k
110
111 check_make k-y -C using_gmake "\$MAKE is not GNU make" \
112                -M "$pr" --keep-going -I kool --include keep-going
113
114 # ----------------------------------------------------------------------
115
116 # Test for when shell metacharacters or backslashes are in $(MAKEFLAGS).
117
118 check_metachars ()
119 {
120   check_make k-n -M "metachars" "$@"
121 }
122
123 check_metachars MYFLAGS="-k \"k\" '-k' --keep-going -k"
124 check_metachars MYFLAGS='-knf2\ k\ \\k'
125 check_metachars MYFLAGS="(&) | ; \" \` '"
126 check_metachars MYFLAGS=" ' # ' "
127 check_metachars MYFLAGS='$(foo)'
128 check_metachars MYFLAGS='$(foo -k)'
129 check_metachars MYFLAGS='`touch bad`'
130 check_metachars MYFLAGS='`touch --keep-going bad`'
131
132 # ----------------------------------------------------------------------
133
134 :