diff options
author | Stefano Lattarini <stefano.lattarini@gmail.com> | 2012-06-23 00:06:10 +0200 |
---|---|---|
committer | Stefano Lattarini <stefano.lattarini@gmail.com> | 2012-06-23 00:06:10 +0200 |
commit | e5343765c216cd8bff74da01986e61c3fe093eb1 (patch) | |
tree | 36e2af783e3fdd6f3fdf308c6e4fd2a2f3ce4562 | |
parent | 465111cdfd1b92feaf9c6fd679cf1845c4e53083 (diff) | |
download | automake-e5343765c216cd8bff74da01986e61c3fe093eb1.tar.gz |
maintcheck: guard against `...` for command substitution in test cases
But still allow them in configure.ac, Makefile.am and shell scripts
created or used inside test cases itself, because Autoconf (as of
version 2.69) does not yet ensure that $CONFIG_SHELL will be set to
a proper POSIX shell.
* syntax-checks.mk (sc_tests_command_subst): New check.
(syntax-check_rules): Add it.
* t/tap-global-log.sh: Minimal tweakings to avoid triggering the
new maintainer check.
Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
-rw-r--r-- | syntax-checks.mk | 28 | ||||
-rwxr-xr-x | t/tap-global-log.sh | 6 |
2 files changed, 32 insertions, 2 deletions
diff --git a/syntax-checks.mk b/syntax-checks.mk index 0549bc8ff..417ae5e8e 100644 --- a/syntax-checks.mk +++ b/syntax-checks.mk @@ -58,6 +58,7 @@ sc_AMDEP_TRUE_in_automake_in \ sc_tests_make_without_am_makeflags \ sc_tests_obsolete_variables \ sc_tests_here_document_format \ +sc_tests_command_subst \ sc_tests_Exit_not_exit \ sc_tests_automake_fails \ sc_tests_required_after_defs \ @@ -341,6 +342,33 @@ sc_tests_here_document_format: exit 1; \ fi +## Our test case should use the $(...) POSIX form for command substitution, +## rather than the older `...` form. +## The point of ignoring text on here-documents is that we want to exempt +## Makefile.am rules, configure.ac code and helper shell script created and +## used by out shell scripts, because Autoconf (as of version 2.69) does not +## yet ensure that $CONFIG_SHELL will be set to a proper POSIX shell. +sc_tests_command_subst: + @found=false; \ + scan () { \ + sed -n -e '/^#/d' \ + -e '/<<.*END/,/^END/b' -e '/<<.*EOF/,/^EOF/b' \ + -e 's/\\`/\\{backtick}/' \ + -e "s/[^\\]'\([^']*\`[^']*\)*'/'{quoted-text}'/g" \ + -e '/`/p' $$*; \ + }; \ + for file in $(xtests); do \ + res=`scan $$file`; \ + if test -n "$$res"; then \ + echo "$$file:$$res"; \ + found=true; \ + fi; \ + done; \ + if $$found; then \ + echo 'Use $$(...), not `...`, for command substitutions.' >&2; \ + exit 1; \ + fi + ## Tests should never call exit directly, but use Exit. ## This is so that the exit status is transported correctly across the 0 trap. ## Ignore comments and our testsuite's own self tests. diff --git a/t/tap-global-log.sh b/t/tap-global-log.sh index 493a5a46d..8267a3d14 100755 --- a/t/tap-global-log.sh +++ b/t/tap-global-log.sh @@ -113,8 +113,10 @@ done grep '^1\.\.0 # SKIP all$' test-suite.log -case `cat test-suite.log` in - *"`cat hodgepodge`"*) ;; +test_suite_contents=$(cat test-suite.log) +hodgepodge_contents=$(cat hodgepodge) +case $test_suite_contents in + *"$hodgepodge_contents"*) ;; *) Exit 1;; esac |