diff options
author | Stefano Lattarini <stefano.lattarini@gmail.com> | 2012-10-28 14:02:46 +0100 |
---|---|---|
committer | Stefano Lattarini <stefano.lattarini@gmail.com> | 2012-10-31 11:39:03 +0100 |
commit | aecd1be61c2d27618a594842501b58bd4ddd8991 (patch) | |
tree | 0f795c087a341b56496a2bb380ce972437d1c3f3 /t/self-check-shell-no-trail-bslash.sh | |
parent | bf016cee0efa2dd3594513791f588b47fa5c456f (diff) | |
download | automake-aecd1be61c2d27618a594842501b58bd4ddd8991.tar.gz |
tests: can check our recipes avoid trailing backslashes
This is related to commit v1.11-1704-g254227b of 2012-05-01,
"parallel-tests: avoid trailing backslashes in make recipes",
and automake bug#10436.
Recipes with a trailing backslash character (possibly followed by
blank characters only) can cause spurious syntax errors with at
least older bash versions (e.g., bash 2.05b), and can be potentially
be unportable to other weaker shells.
So provide a target that runs the testsuite looking for this kind
of breakage (without requiring a real bugged shell).
* t/ax/shell-no-trail-bslash.in: New, a "shell" that chokes on '-c'
commands having a trailing '\' (possibly followed by whitespace only).
* Makefile (t/ax/shell-no-trail-bslash): Generate this script from it.
(noinst_SCRIPTS, CLEANFILES): Add it.
(EXTRA_DIST): Add 't/ax/shell-no-trail-bslash.in'.
(check-no-trailing-backslash-in-recipes): New target, runs the testsuite
with 'shell-no-trail-bslash' as the CONFIG_SHELL, to catch possible
recipes having a trailing backslash character (possibly followed by
* .gitignore: Update.
* t/self-check-shell-no-trail-bslash.sh: New testsuite self-check.
* t/parallel-tests-trailing-bslash.sh: Remove as obsolete.
* t/list-of-tests.mk: Adjust.
Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
Diffstat (limited to 't/self-check-shell-no-trail-bslash.sh')
-rwxr-xr-x | t/self-check-shell-no-trail-bslash.sh | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/t/self-check-shell-no-trail-bslash.sh b/t/self-check-shell-no-trail-bslash.sh new file mode 100755 index 000000000..b7f07f7ff --- /dev/null +++ b/t/self-check-shell-no-trail-bslash.sh @@ -0,0 +1,46 @@ +#! /bin/sh +# Copyright (C) 2012 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# Check that our fake "shell" used to guard against use of trailing +# backslashes in recipes actually complains when those are used. + +# Our hack doesn't work with some make implementations (see comments +# in 't/ax/shell-no-trail-bslash.in' for more details). +required=GNUmake +am_create_testdir=empty +. test-init.sh + +cat >> Makefile <<'END' +am__backslash = \\ # foo +.PHONY: good bad +good: + @printf '%s\n' OK +.PHONY: bad +bad: + @echo $(am__backslash) +END + +SHELL=$am_testauxdir/shell-no-trail-bslash +$SHELL -c 'exit 0' +test "$($SHELL -c 'echo is o\k')" = "is ok" + +$MAKE good + +$MAKE bad SHELL="$SHELL" 2>stderr || { cat stderr >&2; exit 1; } +cat stderr >&2 +$FGREP "recipe ends with backslash character" stderr + +: |