Merge branch 'yacc-quote-fix'
[automake.git] / tests / parallel-tests-trailing-bslash.test
blob418b7222bab488c4c650582c13c36d82df4a80da
1 #! /bin/sh
2 # Copyright (C) 2012 Free Software Foundation, Inc.
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.
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.
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/>.
17 # Check that the new testsuite harness do not generate recipes that can
18 # have a trailing `\', since that can cause spurious syntax errors with
19 # older bash versions (e.g., bash 2.05b).
20 # See automake bug#10436.
22 am_parallel_tests=yes
23 . ./defs || Exit 1
25 echo AC_OUTPUT >> configure.in
27 cat > Makefile.am <<'END'
28 TESTS = foo.test
29 EXTRA_DIST = $(TESTS)
30 am__backslash = \\ # foo
31 .PHONY: bad-recipe
32 bad-recipe:
33 @printf '%s\n' $(am__backslash)
34 END
36 cat > foo.test <<'END'
37 #!/bin/sh
38 exit 0
39 END
40 chmod +x foo.test
42 am__SHELL=$SHELL; export am__SHELL
43 am__PERL=$PERL; export am__PERL
45 cat > my-shell <<'END'
46 #!/bin/sh -e
47 set -u
48 tab=' '
49 nl='
51 am__shell_flags=
52 am__shell_command=; unset am__shell_command
53 while test $# -gt 0; do
54 case $1 in
55 # If the shell is invoked by make e.g. as "sh -ec" (seen on
56 # GNU make in POSIX mode) or "sh -ce" (seen on Solaris make).
57 -*c*)
58 flg=`echo x"$1" | sed -e 's/^x-//' -e 's/c//g'`
59 if test x"$flg" != x; then
60 am__shell_flags="$am__shell_flags -$flg"
62 am__shell_command=$2
63 shift
65 -?*)
66 am__shell_flags="$am__shell_flags $1"
69 break
71 esac
72 shift
73 done
74 if test x${am__shell_command+"set"} != x"set"; then
75 # Some make implementations, like *BSD's, pass the recipes to the shell
76 # through its standard input. Trying to run our extra checks in this
77 # case would be too tricky, so we just skip them.
78 exec $am__SHELL $am__shell_flags ${1+"$@"}
79 else
80 am__tweaked_shell_command=`printf '%s\n' "$am__shell_command" \
81 | tr -d " $tab$nl"`
82 case ${am__tweaked_shell_command-} in
83 *\\)
84 echo "my-shell: recipe ends with backslash character" >&2
85 printf '%s\n' "=== BEGIN recipe" >&2
86 printf '%s\n' "${am__shell_command-}" >&2
87 printf '%s\n' "=== END recipe" >&2
88 exit 99
90 esac
91 exec $am__SHELL $am__shell_flags -c "$am__shell_command" ${1+"$@"}
93 END
94 chmod a+x my-shell
96 cat my-shell
98 CONFIG_SHELL=`pwd`/my-shell; export CONFIG_SHELL
100 $ACLOCAL
101 $AUTOCONF
102 $AUTOMAKE -a
104 ./configure CONFIG_SHELL="$CONFIG_SHELL"
106 st=0
107 $MAKE bad-recipe 2>stderr && st=1
108 cat stderr >&2
109 $FGREP "my-shell: recipe ends with backslash character" stderr || st=1
110 test $st -eq 0 || skip_ "can't catch trailing backslashes in make recipes"
112 $MAKE check