tests: cosmetic changes in t/extra-sources.sh
[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_ 60
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 :: $$MFLAGS ::" ;: For debugging.
37         $(am__make_keepgoing)
38 k-n:
39         @echo ":: $$MAKEFLAGS :: $$MFLAGS ::" ;: For debugging.
40         $(am__make_keepgoing) && exit 1; exit 0
41 END
42
43 check_make ()
44 {
45   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   for opts in '' '-s'  '-s -r'; do
62     r=ok
63     pmsg=${mode}${msg:+" [$msg]"}${opts:+" ($opts)"}
64     if $condition; then
65       $MAKE $opts "$mode" ${1+"$@"} || r='not ok'
66     else
67       directive=SKIP reason=$skip_reason
68     fi
69     result_ "$r" -D "$directive" -r "$reason" "$pmsg"
70   done
71   unset r msg pmsg opts mode condition directive reason skip_reason
72 }
73
74 # ----------------------------------------------------------------------
75
76 $ACLOCAL    || fatal_ "aclocal failed"
77 $AUTOCONF   || fatal_ "autoconf failed"
78 $AUTOMAKE   || fatal_ "automake failed"
79 ./configure || fatal_ "configure failed"
80
81 # ----------------------------------------------------------------------
82
83 check_make k-n
84
85 # Test against a possible regressions similar to those that affected
86 # detection of dry mode ("make -n").
87 check_make k-n TESTS="k.test k2.test"
88 check_make k-n TESTS="k1 k2" AM_MAKEFLAGS="TESTS='k1 k2'"
89 check_make k-n TESTS="k1 k k2" AM_MAKEFLAGS='TESTS="k1 k k2"'
90 check_make k-n FOOFLAGS="-k -k -nkf2 k -ks --keep -k"
91 check_make k-n MYFLAGS="-k --keepgoing -k --keep-run -k"
92
93 # ----------------------------------------------------------------------
94
95 check_make k-y -k
96 check_make k-y -C using_gmake "\$MAKE is not GNU make" --keep-going
97
98 # ----------------------------------------------------------------------
99
100 # Related to automake bug#12554: the "k" in "kool" used to confound
101 # am__make_keepgoing into thinking the '-k' option had been passed.
102
103 pr='bug#12554'
104
105 check_make k-n -C make_supports_option_I "-I make option unsupported" \
106                -M "$pr" -I kool
107
108 check_make k-n -C using_gmake "\$MAKE is not GNU make" \
109                -M "$pr" -I kool --include keep-going
110
111 check_make k-y -C make_supports_option_I "-I make option unsupported" \
112                -M "$pr" -I kool -k
113
114 check_make k-y -C using_gmake "\$MAKE is not GNU make" \
115                -M "$pr" --keep-going -I kool --include keep-going
116
117 # ----------------------------------------------------------------------
118
119 # Test for when shell metacharacters or backslashes are in $(MAKEFLAGS).
120
121 check_metachars ()
122 {
123   check_make k-n -M "metachars" "$@"
124 }
125
126 check_metachars MYFLAGS="-k \"k\" '-k' --keep-going -k"
127 check_metachars MYFLAGS='-knf2\ k\ \\k'
128 check_metachars MYFLAGS="(&) | ; \" \` '"
129 check_metachars MYFLAGS=" ' # ' "
130 check_metachars MYFLAGS='$(foo)'
131 check_metachars MYFLAGS='$(foo -k)'
132 check_metachars MYFLAGS='`touch bad`'
133 check_metachars MYFLAGS='`touch --keep-going bad`'
134
135 # ----------------------------------------------------------------------
136
137 :