From 27136dfe02926ac596c853fced7c17825ef3cf68 Mon Sep 17 00:00:00 2001 From: Stefano Lattarini Date: Sat, 31 Mar 2012 16:39:32 +0200 Subject: init: warn against obsolete usage of AM_INIT_AUTOMAKE Support for the two- and three-arguments invocation forms of the AM_INIT_AUTOMAKE macro, as in: AM_INIT_AUTOMAKE($PACKAGE, $VERSION) or: AM_INIT_AUTOMAKE($PACKAGE, $VERSION, NODEFINE) will be removed in the next major Automake release (1.13). Such usages have already been deprecated in the documentation starting from commit v1.11-2015-ge99690a of 23-02-2012 "docs, news: document planned removal of obsolete macros and features". We now start giving runtime warnings as well (in the 'obsolete' category). * NEWS: Update. * m4/init.m4 (AM_INIT_AUTOMAKE): Report the two- and three-arguments form invocation. * automake.in (scan_autoconf_traces): Likewise. * doc/automake.texi: Minor adjustments. Add an @anchor to the location where it's described how to modernize outdated invocation of AM_INIT_AUTOMAKE, so that it can be referenced from automake warning/error messages. * t/aminit-moreargs-deprecation.sh: New test. * tests/list-of-tests.mk: Add it. * tests/ac-output-old.tap: Adjust by calling automake with the warnings in the 'obsolete' category disabled. * t/backcompat.test: Likewise. * t/backcompat3.test: Likewise. * t/backcompat5.test: Likewise. * t/backcompat6.test: Likewise. * t/version.test: Likewise. * t/version2.test: Likewise. * t/pr2.test: Modernize style of AC_INIT and AM_INIT_AUTOMAKE invocations, and use proper m4 quoting. * t/pr87.test: Likewise. * t/confsub.test: Likewise. * t/install2.test: Likewise. Signed-off-by: Stefano Lattarini --- NEWS | 5 ++++ automake.in | 4 ++++ doc/automake.texi | 3 ++- m4/init.m4 | 5 +++- t/ac-output-old.tap | 2 ++ t/aminit-moreargs-deprecation.sh | 51 ++++++++++++++++++++++++++++++++++++++++ t/backcompat.sh | 2 +- t/backcompat3.sh | 2 ++ t/backcompat5.sh | 4 ++-- t/backcompat6.sh | 2 +- t/confsub.sh | 9 ++++--- t/install2.sh | 12 ++++++---- t/list-of-tests.mk | 1 + t/pr2.sh | 9 +++---- t/pr87.sh | 14 +++++++---- t/version.sh | 2 +- t/version2.sh | 2 +- 17 files changed, 100 insertions(+), 29 deletions(-) create mode 100755 t/aminit-moreargs-deprecation.sh diff --git a/NEWS b/NEWS index dcfd8c1c4..57af90117 100644 --- a/NEWS +++ b/NEWS @@ -56,6 +56,11 @@ New in 1.12.1: * Deprecated obsolescent features: + - Use of the long-deprecated two- and three-arguments invocation forms + of the AM_INIT_AUTOMAKE macro now elicits a warning in the 'obsolete' + category. Starting from the next major Automake release (1.13), such + usages won't be allowed anymore. + - Support for the "Cygnus-style" trees (enabled by the 'cygnus' option) is now deprecated (its use triggers a warning in the 'obsolete' category). It will be removed in the next major Automake release (1.13). diff --git a/automake.in b/automake.in index 16f44b705..5cf5a2c16 100644 --- a/automake.in +++ b/automake.in @@ -5409,6 +5409,10 @@ EOF $seen_init_automake = $where; if (defined $args[2]) { + msg 'obsolete', $where, <<'EOF'; +AM_INIT_AUTOMAKE: two- and three-arguments forms are deprecated. For more info, see: +http://www.gnu.org/software/automake/manual/automake.html#Modernize-AM_INIT_AUTOMAKE-invocation +EOF $package_version = $args[2]; $package_version_location = $where; } diff --git a/doc/automake.texi b/doc/automake.texi index 5e2b9c22b..2f2ebb087 100644 --- a/doc/automake.texi +++ b/doc/automake.texi @@ -3946,13 +3946,14 @@ each option were listed in @code{AUTOMAKE_OPTIONS} (@pxref{Options}). @acindex AC_INIT This macro can also be called in @emph{another, deprecated form} (support -for which will be @emph{removed in the next major Automake release}): +for which will be @emph{removed in the next major Automake release (1.13)}): @code{AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])}. In this form, there are two required arguments: the package and the version number. This form is obsolete because the @var{package} and @var{version} can be obtained from Autoconf's @code{AC_INIT} macro (which itself has an old and a new form). +@anchor{Modernize AM_INIT_AUTOMAKE invocation} If your @file{configure.ac} has: @example diff --git a/m4/init.m4 b/m4/init.m4 index 206034c54..85228ba8c 100644 --- a/m4/init.m4 +++ b/m4/init.m4 @@ -52,7 +52,10 @@ AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], -[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl +[AC_DIAGNOSE([obsolete], +[$0: two- and three-arguments forms are deprecated. For more info, see: +http://www.gnu.org/software/automake/manual/automake.html#Modernize-AM_INIT_AUTOMAKE-invocation]) +m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl diff --git a/t/ac-output-old.tap b/t/ac-output-old.tap index 5c906a2f0..5ba3d3e3a 100755 --- a/t/ac-output-old.tap +++ b/t/ac-output-old.tap @@ -24,6 +24,8 @@ plan_ 22 rm -f configure.ac depcomp # Not required. +AUTOMAKE="$AUTOMAKE -Wno-obsolete" + # ----------------------------------------------------------------------- # Test for bug reported by François Pinard. diff --git a/t/aminit-moreargs-deprecation.sh b/t/aminit-moreargs-deprecation.sh new file mode 100755 index 000000000..ac91d1d1b --- /dev/null +++ b/t/aminit-moreargs-deprecation.sh @@ -0,0 +1,51 @@ +#! /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 . + +# Check that automake warns against old-style usages of AM_INIT_AUTOMAKE +# (i.e., calls with two or three arguments). + +. ./defs || Exit 1 + +warn_rx='AM_INIT_AUTOMAKE.* two-.* three-arguments form.*deprecated' + +cat > configure.ac <<'END' +AC_INIT([Makefile.am]) +AM_INIT_AUTOMAKE([twoargs], [1.0]) +AC_CONFIG_FILES([Makefile]) +END + +$ACLOCAL + +do_check() +{ + rm -rf autom4te*.cache + for cmd in "$AUTOCONF" "$AUTOMAKE"; do + $cmd -Werror -Wnone -Wobsolete 2>stderr && { cat stderr; Exit 1; } + cat stderr >&2 + grep "^configure\.ac:2:.*$warn_rx" stderr + $cmd -Werror -Wall -Wno-obsolete || Exit 1 + done +} + +: > Makefile.am +do_check + +sed "/^AM_INIT_AUTOMAKE/s|)$|, [NODEFINE])|" configure.ac > t +diff configure.ac t && fatal_ "failed to edit configure.ac" +mv -f t configure.ac +do_check + +: diff --git a/t/backcompat.sh b/t/backcompat.sh index ec8292c12..8a93141a9 100755 --- a/t/backcompat.sh +++ b/t/backcompat.sh @@ -55,7 +55,7 @@ END cat configure.in # For debugging. $ACLOCAL $AUTOCONF - $AUTOMAKE + $AUTOMAKE -Wno-obsolete ./configure $MAKE test done diff --git a/t/backcompat3.sh b/t/backcompat3.sh index 2377e8876..5dc78f672 100755 --- a/t/backcompat3.sh +++ b/t/backcompat3.sh @@ -22,6 +22,8 @@ am_create_testdir=empty empty='' +AUTOMAKE="$AUTOMAKE -Wno-obsolete" + cat > Makefile.am <<'END' ## Leading ':;' here required to work around bugs of (at least) bash 3.2 got: Makefile diff --git a/t/backcompat5.sh b/t/backcompat5.sh index 3aa90679e..6bfb1c21e 100755 --- a/t/backcompat5.sh +++ b/t/backcompat5.sh @@ -94,10 +94,10 @@ END $ACLOCAL $AUTOCONF -$AUTOMAKE -a +$AUTOMAKE -a -Wno-obsolete test -f install-sh for f in $makefiles; do mv -f $f.in $f.sav; done -$AUTOMAKE +$AUTOMAKE -Wno-obsolete for f in $makefiles; do diff $f.sav $f.in; done ./configure diff --git a/t/backcompat6.sh b/t/backcompat6.sh index fde118b1c..4523a6567 100755 --- a/t/backcompat6.sh +++ b/t/backcompat6.sh @@ -78,7 +78,7 @@ int main (void) END $ACLOCAL -$AUTOMAKE --add-missing +$AUTOMAKE -Wno-obsolete --add-missing $AUTOCONF ./configure diff --git a/t/confsub.sh b/t/confsub.sh index 188704678..b13f26a3b 100755 --- a/t/confsub.sh +++ b/t/confsub.sh @@ -19,11 +19,10 @@ . ./defs || Exit 1 -cat > configure.ac << 'END' -AC_INIT -AM_INIT_AUTOMAKE(nonesuch, nonesuch) -AM_CONFIG_HEADER(subdir/config.h:subdir/config.hin) -AC_OUTPUT(Makefile subdir/Makefile) +cat >> configure.ac << 'END' +AC_CONFIG_FILES([subdir/Makefile]) +AM_CONFIG_HEADER([subdir/config.h:subdir/config.hin]) +AC_OUTPUT END cat > Makefile.am << 'END' diff --git a/t/install2.sh b/t/install2.sh index f1992e8b1..bd400f427 100755 --- a/t/install2.sh +++ b/t/install2.sh @@ -17,14 +17,16 @@ # Test for bug in 'make dist' # From Pavel Roskin. +am_create_testdir=empty . ./defs || Exit 1 -cat > configure.ac << 'END' -AC_INIT +cat > configure.ac << END +AC_INIT([$me], [1.0]) dnl Prevent automake from looking in .. and ../.. -AC_CONFIG_AUX_DIR(.) -AM_INIT_AUTOMAKE(foo, 0.1) -AC_OUTPUT(Makefile) +AC_CONFIG_AUX_DIR([.]) +AM_INIT_AUTOMAKE +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT END cat > Makefile.am << 'END' diff --git a/t/list-of-tests.mk b/t/list-of-tests.mk index 708e9722a..e9f8d238f 100644 --- a/t/list-of-tests.mk +++ b/t/list-of-tests.mk @@ -117,6 +117,7 @@ t/alpha2.sh \ t/amhello-cflags.sh \ t/amhello-cross-compile.sh \ t/amhello-binpkg.sh \ +t/aminit-moreargs-deprecation.sh \ t/amassign.sh \ t/ammissing.sh \ t/amopt.sh \ diff --git a/t/pr2.sh b/t/pr2.sh index ffe4a81d7..9aa7bc536 100755 --- a/t/pr2.sh +++ b/t/pr2.sh @@ -29,11 +29,8 @@ . ./defs || Exit 1 -# Please keep this underquoted and old-style. -cat > configure.ac << 'END' -AC_INIT -AM_INIT_AUTOMAKE(nonesuch, nonesuch) -AC_OUTPUT(README.foo:templ/README.foo.in Makefile) +cat >> configure.ac << 'END' +AC_OUTPUT([README.foo:templ/README.foo.in]) END : > Makefile.am @@ -46,6 +43,6 @@ $AUTOCONF $AUTOMAKE ./configure $MAKE distdir -test -f nonesuch-nonesuch/templ/README.foo.in +test -f $distdir/templ/README.foo.in : diff --git a/t/pr87.sh b/t/pr87.sh index d98b66152..121328d63 100755 --- a/t/pr87.sh +++ b/t/pr87.sh @@ -37,12 +37,16 @@ EOF done echo "SUBDIRS = $subdirs" > Makefile.am -cat >configure.ac < configure.ac < THANKS $ACLOCAL -$AUTOMAKE --gnits +$AUTOMAKE --gnits -Wno-obsolete diff --git a/t/version2.sh b/t/version2.sh index 71749f64b..273bd3670 100755 --- a/t/version2.sh +++ b/t/version2.sh @@ -38,4 +38,4 @@ END : > THANKS $ACLOCAL -$AUTOMAKE --gnits +$AUTOMAKE --gnits -Wno-obsolete -- cgit v1.2.1 From 1cab373b21e94ce0b5ed833106228ce02ee612fb Mon Sep 17 00:00:00 2001 From: Stefano Lattarini Date: Sun, 6 May 2012 13:33:09 +0200 Subject: fixup: distribute t/README Since commit v1.11-2128-g8e02441 of 2012-04-06, "maint: no more make recursion in Automake's build system" we haven't been distributing the testsuite README file in our release tarballs. Oops. * Makefile.am (EXTRA_DIST): Add 't/README'. Signed-off-by: Stefano Lattarini --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index aab2786f9..5b6cee188 100644 --- a/Makefile.am +++ b/Makefile.am @@ -328,7 +328,7 @@ TAP_LOG_DRIVER = AM_TAP_AWK='$(AWK)' $(SHELL) $(srcdir)/lib/tap-driver.sh AM_TAP_LOG_DRIVER_FLAGS = --merge -EXTRA_DIST += t/ax/is +EXTRA_DIST += t/README t/ax/is TESTS = ## Will be updated later. -- cgit v1.2.1 From 21d1b9342743efdb196110093b3b6ee156688b83 Mon Sep 17 00:00:00 2001 From: Stefano Lattarini Date: Wed, 28 Dec 2011 13:23:31 +0100 Subject: tests: shell running test scripts is now named AM_TEST_RUNNER_SHELL This is just a preparatory refactoring for future changes. * configure.ac (AM_TEST_RUNNER_SHELL): New variable, defined to $SHELL', and AC_SUBST'd. * Makefile.am (LOG_COMPILER): Redefine from $(SHELL) to $(AM_TEST_RUNNER_SHELL). * defs: Adjust to use $AM_TEST_RUNNER_SHELL instead of $CONFIG_SHELL and/or $SHELL, where appropriate. Minor opportunistic changes. * t/self-check-explicit-skips.sh: Likewise. * t/self-check-sanity.sh: Likewise. * t/self-check-tap.sh: Likewise. * t/self-check-cleanup.tap: Likewise. * t/self-check-dir.tap: Likewise. * t/self-check-env-sanitize.tap: Likewise. * t/self-check-exit.tap: Likewise. * t/self-check-me.tap: Likewise. * t/self-check-reexec.tap: Likewise. Signed-off-by: Stefano Lattarini --- Makefile.am | 4 ++-- configure.ac | 4 ++++ defs | 10 +++++----- defs-static.in | 8 +++++++- t/self-check-cleanup.tap | 17 ++++++++++------- t/self-check-dir.tap | 9 +++++---- t/self-check-env-sanitize.tap | 4 ++-- t/self-check-exit.tap | 22 ++++++++++++---------- t/self-check-explicit-skips.sh | 15 +++++++++------ t/self-check-me.tap | 8 ++++---- t/self-check-reexec.tap | 18 ++++++++++++------ t/self-check-sanity.sh | 8 ++++---- t/self-check-tap.sh | 16 +++++++++------- 13 files changed, 85 insertions(+), 58 deletions(-) diff --git a/Makefile.am b/Makefile.am index aab2786f9..0b79a1631 100644 --- a/Makefile.am +++ b/Makefile.am @@ -315,8 +315,8 @@ EXTRA_DIST += m4/amversion.in ## Testsuite. ## ## ------------ ## -# Run the tests with the shell detected at configure time. -LOG_COMPILER = $(SHELL) +# Run the tests with a proper shell detected at configure time. +LOG_COMPILER = $(AM_TEST_RUNNER_SHELL) TEST_EXTENSIONS = .pl .sh .tap SH_LOG_COMPILER = $(LOG_COMPILER) diff --git a/configure.ac b/configure.ac index bda032863..8f3d40fba 100644 --- a/configure.ac +++ b/configure.ac @@ -209,6 +209,10 @@ AC_SUBST([MODIFICATION_DELAY]) AC_PROG_EGREP AC_PROG_FGREP +# Shell used to run our test scripts. The same as $SHELL/$CONFIG_SHELL +# for the moment. +AC_SUBST([AM_TEST_RUNNER_SHELL], [$SHELL]) + AC_CACHE_CHECK([whether $SHELL has working 'set -e' with exit trap], [am_cv_sh_errexit_works], [if $SHELL -ec "trap 'exit \$?' 0; (exit 77); exit 77"; test $? = 77 diff --git a/defs b/defs index 7e9a55427..dd1631a74 100644 --- a/defs +++ b/defs @@ -20,7 +20,7 @@ ######################################################## # NOTE: This file should execute correctly with any system's /bin/sh -# shell, and not only with configure-time detected $CONFIG_SHELL, +# shell, and not only with configure-time detected $AM_TEST_RUNNER_SHELL, # *until differently and explicitly specified*. ## -------------------------------------------------------- ## @@ -105,16 +105,16 @@ case ${AM_TESTS_REEXEC-yes} in *x*) opts=-x;; *) opts=;; esac - echo $me: exec $SHELL $opts "$0" "$*" - exec $SHELL $opts "$0" ${1+"$@"} || { - echo "$me: failed to re-execute with $SHELL" >&2 + echo $me: exec $AM_TEST_RUNNER_SHELL $opts "$0" "$*" + exec $AM_TEST_RUNNER_SHELL $opts "$0" ${1+"$@"} || { + echo "$me: failed to re-execute with $AM_TEST_RUNNER_SHELL" >&2 exit 99 } ;; esac # NOTE: From this point on, we can assume this file is being executed -# by the configure-time detected $CONFIG_SHELL. +# by the configure-time detected $AM_TEST_RUNNER_SHELL. ## ----------------------- ## diff --git a/defs-static.in b/defs-static.in index a8a17f087..30e3253ab 100644 --- a/defs-static.in +++ b/defs-static.in @@ -22,7 +22,8 @@ # - Multiple inclusions of this file should be idempotent. # - This code has to be 'set -e' clean. # - This file should execute correctly with any system's /bin/sh -# shell, not only with configure-time detected $CONFIG_SHELL. +# shell, not only with configure-time detected $SHELL and/or +# $AM_TEST_RUNNER_SHELL. # Be more Bourne compatible. # (Snippet inspired to configure's initialization in Autoconf 2.64) @@ -137,6 +138,11 @@ PATH_SEPARATOR='@PATH_SEPARATOR@' host_alias=${host_alias-'@host_alias@'}; export host_alias build_alias=${build_alias-'@build_alias@'}; export build_alias +# The shell we use to run our own test scripts, determined at configure +# time. It is required in the self tests, and most importantly for the +# the automatic re-execution of test scripts. +AM_TEST_RUNNER_SHELL='@AM_TEST_RUNNER_SHELL@' + # Make sure we override the user shell. And do not read the value of # $SHELL from the environment (think to the non-uncommon situation where # e.g., $SHELL=/bin/tcsh). diff --git a/t/self-check-cleanup.tap b/t/self-check-cleanup.tap index a56854b47..215472ae1 100755 --- a/t/self-check-cleanup.tap +++ b/t/self-check-cleanup.tap @@ -58,7 +58,8 @@ do_clean () # the cleanup code not to be run, so that the temporary directories # are left on disk. command_ok_ '"keep_testdirs=yes" causes testdir to be kept around' eval ' - keep_testdirs=yes $SHELL -c ". ./defs && echo okok >foo" t/dummy.sh \ + env keep_testdirs=yes \ + $AM_TEST_RUNNER_SHELL -c ". ./defs && echo okok >foo" t/dummy.sh \ && test -f t/dummy.dir/foo \ && test okok = `cat t/dummy.dir/foo`' @@ -79,7 +80,7 @@ chmod 000 t/dummy.dir/sub/* t/dummy.dir/file test $have_symlinks = yes && chmod 000 t/dummy.dir/symlink chmod 500 t/dummy.dir/sub t/dummy.dir command_ok_ "pre-cleanup can deal with low-perms testdir" \ - $SHELL -c '. ./defs' t/dummy.sh + $AM_TEST_RUNNER_SHELL -c '. ./defs' t/dummy.sh command_ok_ "pre-cleanup removed low-perms testdir" \ eval 'test ! -f t/dummy.dir \ && test ! -d t/dummy.dir \ @@ -90,7 +91,7 @@ do_clean # Check that post-test cleanup works also with directories with # "null" permissions, and containing broken symlinks. command_ok_ "post-cleanup can deal with low-perms testdir" \ - $SHELL -c ' + $AM_TEST_RUNNER_SHELL -c ' stderr_fileno_=2 . ./defs || Exit 1 set -e @@ -127,7 +128,7 @@ if test $have_symlinks = yes; then (cd t/dummy.dir && ln -s ../../dir ../../file .) command_ok_ "pre-cleanup with testdir with zero-perms symlinks" \ - $SHELL -c '. ./defs' t/dummy.sh + $AM_TEST_RUNNER_SHELL -c '. ./defs' t/dummy.sh ls -l # For debugging. command_ok_ "pre-cleanup chmod doesn't follow symlinks to files" \ eval 'ls -l file | grep "^----------.*file"' @@ -135,7 +136,7 @@ if test $have_symlinks = yes; then eval 'ls -ld dir | grep "^d---------.*dir"' command_ok_ "post-cleanup with testdir with zero-perms symlinks" \ - $SHELL -c ' + $AM_TEST_RUNNER_SHELL -c ' ocwd=`pwd` || exit 1 stderr_fileno_=2 . ./defs || Exit 1 @@ -162,7 +163,8 @@ do_clean # or when receiving a signal. for st in 1 2 3 10 77 99 126 127 130 255; do - command_ok_ "exit trap doesn't clobber exit status $st" not $SHELL -c " + command_ok_ "exit trap doesn't clobber exit status $st" \ + not $AM_TEST_RUNNER_SHELL -c " stderr_fileno_=2 . ./defs : > foo @@ -178,7 +180,8 @@ for sig in 1 2 3 9 13 15; do skip_row_ 2 -r "signal $sig seems blocked" continue fi - command_ok_ "exit trap doesn't clobber signal $sig" not $SHELL -c " + command_ok_ "exit trap doesn't clobber signal $sig" \ + not $AM_TEST_RUNNER_SHELL -c " stderr_fileno_=2 . ./defs : > foo diff --git a/t/self-check-dir.tap b/t/self-check-dir.tap index 736238c35..424367eac 100755 --- a/t/self-check-dir.tap +++ b/t/self-check-dir.tap @@ -27,16 +27,17 @@ plan_ 5 AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC keep_testdirs=; unset keep_testdirs -# This needs to be consistent with what $SHELL deems to be the -# current working directory. -cwd=`$SHELL -c 'pwd'` || fatal_ "can't get current working directory" +# This needs to be consistent with what $AM_TEST_RUNNER_SHELL +# deems to be the current working directory. +cwd=`$AM_TEST_RUNNER_SHELL -c 'pwd'` \ + || fatal_ "can't get current working directory" echo "$cwd" do_check () { test ! -d _self.dir || rm -rf _self.dir \ || framework_failure_ "cleaning up _self.dir" - command_ok_ "$1 [$2]" $SHELL -c " + command_ok_ "$1 [$2]" $AM_TEST_RUNNER_SHELL -c " $2 . ./defs || Exit 99 # Don't fail if 'ls -l' fails; avoids possible racy spurious failures. diff --git a/t/self-check-env-sanitize.tap b/t/self-check-env-sanitize.tap index d4e6cdb69..bc7818610 100755 --- a/t/self-check-env-sanitize.tap +++ b/t/self-check-env-sanitize.tap @@ -40,12 +40,12 @@ vars=' do_run () { - env "$1=foo" $SHELL -c '. ./defs' foo.test + env "$1=foo" $AM_TEST_RUNNER_SHELL -c '. ./defs' foo.test } do_grep () { - env "$1=foo" $SHELL -c '. ./defs' foo.test 2>&1 1>&5 \ + env "$1=foo" $AM_TEST_RUNNER_SHELL -c '. ./defs' foo.test 2>&1 1>&5 \ | grep "foo\.test:.* variable '$1'.* in the environment.*unsafe" } diff --git a/t/self-check-exit.tap b/t/self-check-exit.tap index c866dbc28..029b17424 100755 --- a/t/self-check-exit.tap +++ b/t/self-check-exit.tap @@ -38,12 +38,12 @@ AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC init='stderr_fileno_=2; unset am_explicit_skips; . ./defs' # Required so that the code in defs doesn't go crazy trying to creating a -# temporary directory in the absolute dir of $SHELL. +# temporary directory in the absolute dir of $AM_TEST_RUNNER_SHELL. dummy_test_script=t/$me.sh for st in 1 2 3 4 5 77 99 126 127 128 129 130 255; do for exit_cmd in "Exit $st" "sh -c 'exit $st'"; do - $SHELL -c "$init; $exit_cmd; :" "$dummy_test_script" + $AM_TEST_RUNNER_SHELL -c "$init; $exit_cmd; :" "$dummy_test_script" command_ok_ "$exit_cmd" test $? -eq $st done done @@ -54,12 +54,12 @@ for sig in 1 2 13 15; do continue fi if test $sig -eq 2; then - # Some Korn shells might otherwise get a spurious SIGINT signal when - # one is sent to the child $SHELL. For more details, see: + # Some Korn shells might otherwise get a spurious SIGINT when one is + # sent to the child $AM_TEST_RUNNER_SHELL. For more details, see: # trap : 2 fi - $SHELL -c "$init; kill -$sig \$\$; :" "$dummy_test_script" + $AM_TEST_RUNNER_SHELL -c "$init; kill -$sig \$\$; :" "$dummy_test_script" rc=$? if test $sig -eq 2; then # Reset default SIGINT handler as portably as possible. @@ -88,25 +88,27 @@ done # 3. a non-existing command is issued. # Note that the non-existent command is issued as the last command to # the shell in the next line; this is deliberate. -if $SHELL -c 'set -e; trap "exit \$?" 0; non-existent-program'; then +# FIXME: remove this workaround once we have a better configure-time +# determination of '$AM_TEST_RUNNER_SHELL'. +if $AM_TEST_RUNNER_SHELL -c 'set -e; trap "exit \$?" 0; non-existent-program'; then maybe_todo=TODO reason="known Solaris /bin/sh bug" else maybe_todo="" reason="" fi -$SHELL -c "$init; non-existent-program; :" "$dummy_test_script" +$AM_TEST_RUNNER_SHELL -c "$init; non-existent-prog; :" "$dummy_test_script" command_ok_ "command not found" -D "$maybe_todo" -r "$reason" \ -- test $? -gt 0 : Non-executable command. test -f Makefile && test ! -x Makefile || \ framowork_failure_ "no proper Makefile in the current directory" -$SHELL -c "$init; ./Makefile; :" "$dummy_test_script" +$AM_TEST_RUNNER_SHELL -c "$init; ./Makefile; :" "$dummy_test_script" command_ok_ "permission denied" test $? -gt 0 : Syntax errors in the test code. -$SHELL -c "$init; if :; then" "$dummy_test_script" +$AM_TEST_RUNNER_SHELL -c "$init; if :; then" "$dummy_test_script" command_ok_ "syntax error 1" test $? -gt 0 -$SHELL -c "$init; fi" "$dummy_test_script" +$AM_TEST_RUNNER_SHELL -c "$init; fi" "$dummy_test_script" command_ok_ "syntax error 2" test $? -gt 0 : diff --git a/t/self-check-explicit-skips.sh b/t/self-check-explicit-skips.sh index 3e7a77c0a..2b64fe156 100755 --- a/t/self-check-explicit-skips.sh +++ b/t/self-check-explicit-skips.sh @@ -35,22 +35,25 @@ set +e unset am_explicit_skips stderr_fileno_ AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC -$SHELL -c '. ./defs; (exit 77); exit 77' dummy.test +# I'm a lazy typist. +sh=$AM_TEST_RUNNER_SHELL + +$sh -c '. ./defs; (exit 77); exit 77' dummy.test test $? -eq 77 || Exit 1 -am_explicit_skips=no $SHELL -c '. ./defs; sh -c "exit 77"' dummy.test +am_explicit_skips=no $sh -c '. ./defs; sh -c "exit 77"' dummy.test test $? -eq 77 || Exit 1 -am_explicit_skips=yes $SHELL -c '. ./defs; (exit 77); exit 77' dummy.test +am_explicit_skips=yes $sh -c '. ./defs; (exit 77); exit 77' dummy.test test $? -eq 78 || Exit 1 -am_explicit_skips=y $SHELL -c '. ./defs; sh -c "exit 77"' dummy.test +am_explicit_skips=y $sh -c '. ./defs; sh -c "exit 77"' dummy.test test $? -eq 78 || Exit 1 -am_explicit_skips=yes $SHELL -c '. ./defs; Exit 77' dummy.test +am_explicit_skips=yes $sh -c '. ./defs; Exit 77' dummy.test test $? -eq 77 || Exit 1 -am_explicit_skips=y $SHELL -c '. ./defs; skip_ "foo"' dummy.test +am_explicit_skips=y $sh -c '. ./defs; skip_ "foo"' dummy.test test $? -eq 77 || Exit 1 : diff --git a/t/self-check-me.tap b/t/self-check-me.tap index 5c83ee6d3..cddc9b5d7 100755 --- a/t/self-check-me.tap +++ b/t/self-check-me.tap @@ -32,7 +32,7 @@ set +e do_check () { - $SHELL -c '. ./defs && echo me=$me' "$1" | grep "^me=$2$" + $AM_TEST_RUNNER_SHELL -c '. ./defs && echo me=$me' "$1" | grep "^me=$2$" command_ok_ "me=$1" test $? -eq 0 } @@ -48,7 +48,7 @@ do_check abc. 'abc\.' # If we override $me, ./defs should not modify it. -s=`$SHELL -c 'me=foo.sh && . ./defs && echo me=$me' bad.sh` +s=`$AM_TEST_RUNNER_SHELL -c 'me=foo.sh && . ./defs && echo me=$me' bad.sh` command_ok_ "override of \$me before ./defs causes no error" \ test $? -eq 0 @@ -59,8 +59,8 @@ result_ "$r" "override of \$me before ./defs is honored" unset r # Overriding $me after sourcing ./defs-static should work. -s=`$SHELL -c '. ./defs-static && me=zardoz && - . ./defs && echo me=$me' bad.sh` +s=`$AM_TEST_RUNNER_SHELL -c '. ./defs-static && me=zardoz && + . ./defs && echo me=$me' bad.sh` command_ok_ "override of \$me after ./defs-static causes no error" \ test $? -eq 0 diff --git a/t/self-check-reexec.tap b/t/self-check-reexec.tap index 8237c0812..7b91008ec 100755 --- a/t/self-check-reexec.tap +++ b/t/self-check-reexec.tap @@ -16,7 +16,7 @@ # Sanity check for the automake testsuite. # Check that automatic re-execution of test script with the -# configure-time $SHELL. +# configure-time $AM_TEST_RUNNER_SHELL. am_create_testdir=empty . ./defs || Exit 1 @@ -32,7 +32,9 @@ cp "$am_top_builddir"/defs . || fatal_ "fetching 'defs' from top_builddir" # Search for required bash and non-bash shells. # -for bash_shell in "$SHELL" bash bash3 bash4 :; do +for bash_shell in \ + "$SHELL" "$AM_TEST_RUNNER_SHELL" bash bash3 bash4 : +do test "$bash_shell" = : && break $bash_shell --version || continue $bash_shell -c 'test -n "$BASH_VERSION"' || continue @@ -41,7 +43,9 @@ done # This might not be optimal, but it's much better than writing wrapper # scripts acting as "fake" shells. -for non_bash_shell in /bin/sh /bin/ksh "$SHELL" sh ksh ash dash pdksh :; do +for non_bash_shell in \ + /bin/sh /bin/ksh sh ksh ash dash pdksh "$SHELL" "$AM_TEST_RUNNER_SHELL" : +do test "$non_bash_shell" = : && break $non_bash_shell -c 'exit 0' || continue $non_bash_shell -c 'test -n "$BASH_VERSION"' && continue @@ -97,8 +101,9 @@ cat > need-bash.sh <<'END' (foo=abac && test xbxc = ${foo//a/x} && test -n "$BASH_VERSION") END +sh_var=AM_TEST_RUNNER_SHELL sed -e "s|^am_top_builddir=.*|am_top_builddir='$cwd'|" \ - -e 's|^SHELL=.*$|SHELL=bash; export SHELL|' \ + -e "s|^$sh_var=.*$|$sh_var=bash; export $sh_var|" \ < "$am_top_builddir"/defs-static >defs-static do_reexec () @@ -169,12 +174,13 @@ check_reexec_message () dir=$1; shift get_ddata "$dir" $sh "${dir}${dsep}dummy.sh" "$@" \ - | grep "^dummy: exec $SHELL ${dir}${dsep}dummy\\.sh $*\$" \ + | grep "^dummy: exec $AM_TEST_RUNNER_SHELL ${dir}${dsep}dummy\\.sh $*\$" \ && r='ok' || r='not ok' result_ "$r" "$sh display re-exec message [$dname] [args: $*]" } -./dummy.sh a b | grep "^dummy: exec $SHELL \\./dummy\\.sh a b$" \ +./dummy.sh a b \ + | grep "^dummy: exec $AM_TEST_RUNNER_SHELL \\./dummy\\.sh a b$" \ && r='ok' || r='not ok' result_ "$r" "direct run display re-exec message [args: a b]" diff --git a/t/self-check-sanity.sh b/t/self-check-sanity.sh index 64e489cb7..8e31afa1c 100755 --- a/t/self-check-sanity.sh +++ b/t/self-check-sanity.sh @@ -32,7 +32,7 @@ AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC source_defs=". '$am_top_builddir/defs'" -if $SHELL -c "$source_defs" dummy.test 2>stderr; then +if $AM_TEST_RUNNER_SHELL -c "$source_defs" dummy.sh 2>stderr; then show_stderr Exit 1 else @@ -42,7 +42,7 @@ fi sed 's|^am_top_srcdir=.*|am_top_srcdir=foo|' \ "$am_top_builddir"/defs-static > defs-static -if $SHELL -c "$source_defs" t/dummy.test 2>stderr; then +if $AM_TEST_RUNNER_SHELL -c "$source_defs" t/dummy.sh 2>stderr; then show_stderr Exit 1 else @@ -52,7 +52,7 @@ fi sed 's|^am_top_builddir=.*|am_top_builddir=foo|' \ "$am_top_builddir"/defs-static > defs-static -if $SHELL -c "$source_defs" t/dummy.test 2>stderr; then +if $AM_TEST_RUNNER_SHELL -c "$source_defs" t/dummy.sh 2>stderr; then show_stderr Exit 1 else @@ -71,7 +71,7 @@ env \ top_builddir=bad-dir top_srcdir=bad-dir \ abs_builddir=bad-dir abs_srcdir=bad-dir \ abs_top_builddir=bad-dir abs_top_srcdir=bad-dir \ - $SHELL -c "$source_defs && echo '!OK!' > ../foo" t/dummy.test + $AM_TEST_RUNNER_SHELL -c "$source_defs && echo '!OK!' > ../foo" t/dummy.sh $FGREP '!OK!' t/foo : diff --git a/t/self-check-tap.sh b/t/self-check-tap.sh index 6a2d132fd..d7f788c6b 100755 --- a/t/self-check-tap.sh +++ b/t/self-check-tap.sh @@ -22,19 +22,21 @@ set -ex -$SHELL -c '. ./defs-static && test $am_using_tap = yes' foo.tap -$SHELL -c '. ./defs-static && test $am_using_tap = no' foo.test -$SHELL -c '. ./defs-static && test $am_using_tap = no' tap -$SHELL -c '. ./defs-static && test $am_using_tap = no' tap.test -$SHELL -c '. ./defs-static && test $am_using_tap = no' foo-tap +$AM_TEST_RUNNER_SHELL -c \ + '. ./defs-static && test $am_using_tap = yes' foo.tap -$SHELL -c ' +for name in foo.test tap tap.test foo-tap; do + $AM_TEST_RUNNER_SHELL -c \ + '. ./defs-static && test $am_using_tap = no' $name +done + +$AM_TEST_RUNNER_SHELL -c ' am_using_tap=no . ./defs-static test $am_using_tap = no ' foo.tap -$SHELL -c ' +$AM_TEST_RUNNER_SHELL -c ' am_using_tap=yes . ./defs-static test $am_using_tap = yes -- cgit v1.2.1 From 2d68fd9b481762a31847cf412fedb68decf6e8fd Mon Sep 17 00:00:00 2001 From: Stefano Lattarini Date: Wed, 28 Dec 2011 13:23:31 +0100 Subject: configure: search a sturdy POSIX shell to be used in the testsuite * configure.ac: Add code (partially inspired to checks in gnulib's 'tests/init.sh') to search for a good-enough, not-buggy POSIX/XSI shell to be used in our testsuite. Accordingly AC_SUBSTitute the variable 'AM_TEST_RUNNER_SHELL'. * NEWS: Update. Signed-off-by: Stefano Lattarini --- NEWS | 11 ++++ configure.ac | 190 +++++++++++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 184 insertions(+), 17 deletions(-) diff --git a/NEWS b/NEWS index e7570d0b3..0707a8201 100644 --- a/NEWS +++ b/NEWS @@ -60,6 +60,17 @@ New in 1.12.1: m4 macro are deprecated, eliciting a warning in the 'obsolete' category. They will be removed in the next major version (1.13). +* Miscellaneous changes: + + - The Automake test cases now require a proper POSIX-conforming shell. + Older non-POSIX Bourne shells (like Solaris 10 /bin/sh) won't be + accepted anymore. In most cases, the user shouldn't have to specify + such POSIX shell explicitly, since it will be looked up at configure + time. Still, when this lookup fails, or when the user wants to + override its conclusion, the variable 'AM_TEST_RUNNER_SHELL' can be + used (pointing to the shell that will be used to run the Automake + test cases). + Bugs fixed in 1.12.1: * Bugs introduced by 1.12: diff --git a/configure.ac b/configure.ac index 8f3d40fba..ecca49b2a 100644 --- a/configure.ac +++ b/configure.ac @@ -205,29 +205,185 @@ case $build in esac AC_SUBST([MODIFICATION_DELAY]) -# Test for things needed by the test suite. +## ------------------------------------------- ## +## Test for things needed by the test suite. ## +## ------------------------------------------- ## + AC_PROG_EGREP AC_PROG_FGREP -# Shell used to run our test scripts. The same as $SHELL/$CONFIG_SHELL -# for the moment. -AC_SUBST([AM_TEST_RUNNER_SHELL], [$SHELL]) +dnl FIXME: could we extract this in a simpler way through autoconf +dnl FIXME: idioms or internals? +AC_DEFUN( + [_AM_INIT_BOURNE_COMPATIBLE_VAR], + [am_bourne_compatible="AS_ESCAPE(_m4_expand([AS_BOURNE_COMPATIBLE]))"]) + +dnl +dnl Arguments to this macro: +dnl +dnl $1 - shell to test +dnl $2 - description of the tested feature +dnl $3 - shell code used to check the feature; to indicate success, +dnl it can either exit with status 77, or have the last command +dnl returning with exit status of zero +dnl $4 - shell code to execute if the check on the shell is successful +dnl (defaults to nothing) +dnl $5 - shell code to execute if the check on the shell is not +dnl successful (defaults to nothing) +dnl +AC_DEFUN([_AM_CHECK_SHELL_FEATURE], + [AC_REQUIRE([_AM_INIT_BOURNE_COMPATIBLE_VAR]) + AC_MSG_CHECKING([whether $1 $2]) + if { $1 -c "$am_bourne_compatible +AS_ESCAPE([$3]) +test \$? -eq 0 || exit 1 +# Use 77 to indicate success (rather than 0), in case some shell +# acts like Solaris 10's /bin/sh, exiting successfully on some +# syntax errors. +exit 77" >&AS_MESSAGE_LOG_FD 2>&1; test $? -eq 77; } + then + AC_MSG_RESULT([yes]) + $4 + else + AC_MSG_RESULT([no]) + $5 + fi]) + +# AM_CHECK_CANDIDATE_TEST_SHELL(SHELL-PATH) +# ----------------------------------------- +# +# Check if the given shell is good enough to run our test scripts. +# Inspired to gnulib's 'tests/init.sh'. +# +# We require POSIX and XSI features (e.g., '$(...)' for command +# substitutions, '$((...))' for shell arithmetic, and support for +# '${var#...}' and '${var%...}' parameter expansions). +# +# We require that the shell can correctly trap EXIT when 'set -e' is in +# effect (OSF1/Tru64 sh failed to do so, see commit v1.10b-52-g9fe8259). +# +# We also prefer shells that, when 'set -x' is in effect, do not also +# redirect traces upon stderr redirections. For example, +# $ set -x; echo x 2>file +# would emit "+ echo x" into file with older zsh versions. Similarly, +# $ set -x; P=1 true 2>file +# would emit "P=1" into file with /usr/xpg4/bin/sh from Solaris 10 and +# /bin/sh from SunOS 5.11 and OpenBSD 4.7. +# +# Finally, we look for weird bugs and portability problems mentioned in +# the Autoconf manual, and reject shells that suffers from them. (TODO) +# +# Use '$am_score' to indicate the degree of acceptability of the shell. +# A score of "10" means that the shell is good enough for our needs; +# a score of "9" means that the shell has some minor bugs or limitation, +# but is still (barely) acceptable for our uses. Any other score means +# that the shell is broken or unfit. +# +AC_DEFUN([_AM_CHECK_CANDIDATE_SHELL], + [am_score=10 + while :; do -AC_CACHE_CHECK([whether $SHELL has working 'set -e' with exit trap], -[am_cv_sh_errexit_works], -[if $SHELL -ec "trap 'exit \$?' 0; (exit 77); exit 77"; test $? = 77 -then - am_cv_sh_errexit_works=yes + _AM_CHECK_SHELL_FEATURE([$1], + [supports \$(cmd)], + [test "$(echo x)" = x], + [], [am_score=1; break]) + + _AM_CHECK_SHELL_FEATURE([$1], + [supports \$((expr))], + [test $((1 + 2 * 3)) = 7], + [], [am_score=1; break]) + + _AM_CHECK_SHELL_FEATURE([$1], + [supports \${var@%:@glob}], + [v=a/b/c; test ${v@%:@*/} = b/c], + [], [am_score=1; break]) + + _AM_CHECK_SHELL_FEATURE([$1], + [supports \${var@%:@@%:@glob}], + [v=a/b/c; test ${v@%:@@%:@*/} = c], + [], [am_score=1; break]) + + _AM_CHECK_SHELL_FEATURE([$1], + [supports \${var%glob}], + [v=a.b.c; test ${v%.*} = a.b], + [], [am_score=1; break]) + + _AM_CHECK_SHELL_FEATURE([$1], + [supports \${var%%glob}], + [v=a.b.c; test ${v%%.*} = a], + [], [am_score=1; break]) + + _AM_CHECK_SHELL_FEATURE([$1], + ["set -e" preserves exit traps], + [set -e; trap 'exit $?' 0; (exit 77); exit 77], + [], [am_score=1; break]) + + _AM_CHECK_SHELL_FEATURE([$1], + ["set -x" corrupts stderr], + [(set -x; P=1 true 2>&3) 3>&1 2>/dev/null | grep P=1], + [am_score=9], []) + + break + done]) + +# These messages only goes to the config.log file. +AC_MSG_NOTICE([will now look for a sturdy POSIX shell, for our testsuite]) + +AC_CACHE_VAL( + [ac_cv_AM_TEST_RUNNER_SHELL], + [if test "$AM_TEST_RUNNER_SHELL"; then + # Let the user override it. + ac_cv_AM_TEST_RUNNER_SHELL=$AM_TEST_RUNNER_SHELL + else + ac_cv_AM_TEST_RUNNER_SHELL=no + am_candidate_shells=${CONFIG_SHELL-} + # For the benefit of Solaris. + am_PATH=$PATH$PATH_SEPARATOR/usr/xpg6/bin$PATH_SEPARATOR/usr/xpg4/bin + for am_sh in sh sh5 dash ash bash zsh ksh pdksh; do + AC_PATH_PROG([am_candidate_sh], [$am_sh], [], [$am_PATH]) + if test -n "$am_candidate_sh"; then + am_candidate_shells="$am_candidate_shells $am_candidate_sh" + fi + AM_SUBST_NOTMAKE([am_candidate_sh]) + # Must nullify these in order not to interfere with the checks in + # the next loop. + AS_UNSET([am_candidate_sh]) + AS_UNSET([ac_cv_path_am_candidate_sh]) + done + AS_UNSET([am_PATH]) # Not required anymore + for am_sh in $am_candidate_shells; do + am_score=0 + _AM_CHECK_CANDIDATE_SHELL([$am_sh]) + if test $am_score -eq 9; then + # The shell is barely acceptable for our needs. We might + # still find one that is even better, so continue looking. + AC_MSG_NOTICE([shell $am_sh is acceptable, but we might do better]) + ac_cv_AM_TEST_RUNNER_SHELL=$am_sh + elif test $am_score -eq 10; then + AC_MSG_NOTICE([shell $am_sh is good enough, stop looking]) + ac_cv_AM_TEST_RUNNER_SHELL=$am_sh + break + fi + done + fi + AM_TEST_RUNNER_SHELL=$ac_cv_AM_TEST_RUNNER_SHELL]) + +if test $AM_TEST_RUNNER_SHELL = no; then + AC_MSG_FAILURE([m4_normalize([no POSIX shell found that is good + enough to be used in our testsuite])]) else - am_cv_sh_errexit_works=no -fi -]) -if test $am_cv_sh_errexit_works = no; then - AC_MSG_WARN(["${MAKE-make} check" will leave leftover directories t/*.dir]) - AC_MSG_WARN([you can clean them up manually using "${MAKE-make} clean" or]) - AC_MSG_WARN(["cd t && ${MAKE-make} clean-local-check']) + AC_MSG_NOTICE([will use $AM_TEST_RUNNER_SHELL as the testsuite shell]) fi -AC_SUBST([sh_errexit_works], [$am_cv_sh_errexit_works]) + +AC_ARG_VAR([AM_TEST_RUNNER_SHELL], + [a sturdy POSIX shell for our testsuite]) + +# FIXME: remove soon +AC_SUBST([sh_errexit_works], [yes]) + +## ---------------------- ## +## Create output files. ## +## ---------------------- ## ########################################################################### -- cgit v1.2.1 From 6b641de5fc4ecf679d77a7542f83b1d04402c798 Mon Sep 17 00:00:00 2001 From: Stefano Lattarini Date: Wed, 28 Dec 2011 13:23:31 +0100 Subject: tests: remove obsolete uses of $sh_errexit_works After the last changes, configure will ensure that the shell selected to run the test scripts can correctly propagate exit status to the exit trap when 'set -e' is in effect. * configure.ac (sh_errexit_works): Do not AC_SUBST it anymore. * defs-static.in (sh_errexit_works): Do not initialize from the AC_SUBST value anymore. * defs (trap): Trap the EXIT signal unconditionally. * t/self-check-explicit-skips.sh: Do not skip the test if '$sh_errexit_works' is != "yes", this check doesn't make sense anymore. * t/self-check-cleanup.tap: Likewise. * t/self-check-exit.tap: Assume the exit trap is always installed by ./defs. Signed-off-by: Stefano Lattarini --- configure.ac | 3 --- defs | 3 +-- defs-static.in | 3 --- t/self-check-cleanup.tap | 4 ---- t/self-check-exit.tap | 13 +------------ t/self-check-explicit-skips.sh | 2 -- 6 files changed, 2 insertions(+), 26 deletions(-) diff --git a/configure.ac b/configure.ac index ecca49b2a..7be255469 100644 --- a/configure.ac +++ b/configure.ac @@ -378,9 +378,6 @@ fi AC_ARG_VAR([AM_TEST_RUNNER_SHELL], [a sturdy POSIX shell for our testsuite]) -# FIXME: remove soon -AC_SUBST([sh_errexit_works], [yes]) - ## ---------------------- ## ## Create output files. ## ## ---------------------- ## diff --git a/defs b/defs index dd1631a74..4c1e40d85 100644 --- a/defs +++ b/defs @@ -1001,7 +1001,7 @@ case " $required " in *\ gettext*) . ./t/gettext-macros.dir/get.sh;; esac distdir=$me-1.0 # Set up the exit trap. -if test "$sh_errexit_works" = yes; then +# FIXME: adjust indentation, here and below. trap 'exit_status=$? set +e cd "$am_top_builddir" @@ -1059,7 +1059,6 @@ if test "$sh_errexit_works" = yes; then # See also Test::Harness bug [rt.cpan.org #70855], archived at # trap "trap '' 13; fatal_ 'caught signal SIGPIPE'" 13 -fi # Create and populate the temporary directory, if and as required. if test x"$am_create_testdir" = x"no"; then diff --git a/defs-static.in b/defs-static.in index 30e3253ab..44db30953 100644 --- a/defs-static.in +++ b/defs-static.in @@ -222,9 +222,6 @@ GNU_GCJFLAGS=${AM_TESTSUITE_GNU_GCJFLAGS-${GNU_GCJFLAGS-'@GNU_GCJFLAGS@'}} # this variable. TEX=${AM_TESTSUITE_TEX-'@TEX@'} -# Whether $SHELL has working 'set -e' with exit trap. -sh_errexit_works='@sh_errexit_works@' - # The amount we should wait after modifying files depends on the platform. # For instance, Windows '95, '98 and ME have 2-second granularity # and can be up to 3 seconds in the future w.r.t. the system clock. diff --git a/t/self-check-cleanup.tap b/t/self-check-cleanup.tap index 215472ae1..21c638891 100755 --- a/t/self-check-cleanup.tap +++ b/t/self-check-cleanup.tap @@ -19,10 +19,6 @@ . ./defs || Exit 1 -if test x"$sh_errexit_works" != x"yes"; then - skip_all_ "$me: no working exit trap with 'set -e'" -fi - plan_ 43 # We still need a little hack to make ./defs work outside automake's diff --git a/t/self-check-exit.tap b/t/self-check-exit.tap index 029b17424..1d3c0202b 100755 --- a/t/self-check-exit.tap +++ b/t/self-check-exit.tap @@ -65,18 +65,7 @@ for sig in 1 2 13 15; do # Reset default SIGINT handler as portably as possible. trap 2 || trap - 2 fi - if test x"$sh_errexit_works" = x"yes"; then - # The exit trap should turn into an hard errors any failure - # caused by signals. - command_ok_ "kill -$sig" test $rc -eq 99 - else - # The exit trap is not installed, so that the shell should exit - # with status 128+n when receiving signal number n. But don't - # be too strict in the check, as POSIX only says that "The exit - # status of a command that terminated because it received a - # signal shall be reported as greater than 128". - command_ok_ "kill -$sig" test $rc -gt 128 - fi + command_ok_ "kill -$sig" test $rc -eq 99 unset rc done diff --git a/t/self-check-explicit-skips.sh b/t/self-check-explicit-skips.sh index 2b64fe156..7a92671de 100755 --- a/t/self-check-explicit-skips.sh +++ b/t/self-check-explicit-skips.sh @@ -20,8 +20,6 @@ am_create_testdir=empty . ./defs || Exit 1 -test x"$sh_errexit_works" = x"yes" || skip_ "no working shell exit trap" - # We still need a little hack to make ./defs work outside automake's # tree 'tests' subdirectory. Not a big deal. sed "s|^am_top_builddir=.*|am_top_builddir='`pwd`'|" \ -- cgit v1.2.1 From 1cf7d18839c7f9d878a322f841e1be8845d83514 Mon Sep 17 00:00:00 2001 From: Stefano Lattarini Date: Wed, 28 Dec 2011 13:23:31 +0100 Subject: test defs: fix indentation (cosmetic change) * defs (exit trap): Fix indentation left botched by previous patch 'v1.11b-51-g626bf65'. Signed-off-by: Stefano Lattarini --- defs | 113 +++++++++++++++++++++++++++++++++---------------------------------- 1 file changed, 56 insertions(+), 57 deletions(-) diff --git a/defs b/defs index 4c1e40d85..fcdbb7df4 100644 --- a/defs +++ b/defs @@ -1001,64 +1001,63 @@ case " $required " in *\ gettext*) . ./t/gettext-macros.dir/get.sh;; esac distdir=$me-1.0 # Set up the exit trap. -# FIXME: adjust indentation, here and below. - trap 'exit_status=$? - set +e - cd "$am_top_builddir" - if test $am_using_tap = yes; then - if test "$planned_" = later && test $exit_status -eq 0; then - plan_ "now" - fi - test $exit_status -eq 0 && test $tap_pass_count_ -eq $tap_count_ \ - || keep_testdirs=yes - else - # This is to ensure that a test script does give a SKIP outcome just - # because a command in it happens to exit with status 77. This - # behaviour, while from time to time useful to developers, is not - # meant to be enabled by default, as it could cause spurious failures - # in the wild. Thus it will be enabled only when the variable - # "am_explicit_skips" is set to a "true" value. - case $am_explicit_skips in - [yY]|[yY]es|1) - if test $exit_status -eq 77 && test $am__test_skipped != yes; then - echo "$me: implicit skip turned into failure" - exit_status=78 - fi;; - esac - test $exit_status -eq 0 || keep_testdirs=yes +trap 'exit_status=$? + set +e + cd "$am_top_builddir" + if test $am_using_tap = yes; then + if test "$planned_" = later && test $exit_status -eq 0; then + plan_ "now" fi - am_keeping_testdirs || rm_rf_ $testSubDir - set +x - echo "$me: exit $exit_status" - exit $exit_status - ' 0 - trap "fatal_ 'caught signal SIGHUP'" 1 - trap "fatal_ 'caught signal SIGINT'" 2 - trap "fatal_ 'caught signal SIGTERM'" 15 - # Various shells seems to just ignore SIGQUIT under some circumstances, - # even if the signal is not blocked; however, if the signal it trapped, - # the trap gets correctly executed. So we also trap SIGQUIT. - # Here is a list of some shells that have been verified to exhibit the - # problematic behavior with SIGQUIT: - # - zsh 4.3.12 on Debian GNU/Linux - # - /bin/ksh and /usr/xpg4/bin/sh on Solaris 10 - # - Bash 3.2.51 on Solaris 10 and bash 4.1.5 on Debian GNU/Linux - # - AT&T ksh on Debian Gnu/Linux (deb package ksh, version 93u-1) - # OTOH, at least these shells that do *not* exhibit that behaviour: - # - modern version of the Almquist Shell (at least 0.5.5.1), on - # both Solaris and GNU/Linux - # - Solaris 10 /bin/sh - # - public domain Korn Shell, version 5.2.14, on Debian GNU/Linux - trap "fatal_ 'caught signal SIGQUIT'" 3 - # Ignore further SIGPIPE in the trap code. This is required to avoid - # a very weird issue with some shells, at least when the execution of - # the automake testsuite is driven by the 'prove' utility: if prove - # (or the make process that has spawned it) gets interrupted with - # Ctrl-C, the shell might go in a loop, continually getting a SIGPIPE, - # sometimes finally dumping core, other times hanging indefinitely. - # See also Test::Harness bug [rt.cpan.org #70855], archived at - # - trap "trap '' 13; fatal_ 'caught signal SIGPIPE'" 13 + test $exit_status -eq 0 && test $tap_pass_count_ -eq $tap_count_ \ + || keep_testdirs=yes + else + # This is to ensure that a test script does give a SKIP outcome just + # because a command in it happens to exit with status 77. This + # behaviour, while from time to time useful to developers, is not + # meant to be enabled by default, as it could cause spurious failures + # in the wild. Thus it will be enabled only when the variable + # "am_explicit_skips" is set to a "true" value. + case $am_explicit_skips in + [yY]|[yY]es|1) + if test $exit_status -eq 77 && test $am__test_skipped != yes; then + echo "$me: implicit skip turned into failure" + exit_status=78 + fi;; + esac + test $exit_status -eq 0 || keep_testdirs=yes + fi + am_keeping_testdirs || rm_rf_ $testSubDir + set +x + echo "$me: exit $exit_status" + exit $exit_status +' 0 +trap "fatal_ 'caught signal SIGHUP'" 1 +trap "fatal_ 'caught signal SIGINT'" 2 +trap "fatal_ 'caught signal SIGTERM'" 15 +# Various shells seems to just ignore SIGQUIT under some circumstances, +# even if the signal is not blocked; however, if the signal it trapped, +# the trap gets correctly executed. So we also trap SIGQUIT. +# Here is a list of some shells that have been verified to exhibit the +# problematic behavior with SIGQUIT: +# - zsh 4.3.12 on Debian GNU/Linux +# - /bin/ksh and /usr/xpg4/bin/sh on Solaris 10 +# - Bash 3.2.51 on Solaris 10 and bash 4.1.5 on Debian GNU/Linux +# - AT&T ksh on Debian Gnu/Linux (deb package ksh, version 93u-1) +# OTOH, at least these shells that do *not* exhibit that behaviour: +# - modern version of the Almquist Shell (at least 0.5.5.1), on +# both Solaris and GNU/Linux +# - Solaris 10 /bin/sh +# - public domain Korn Shell, version 5.2.14, on Debian GNU/Linux +trap "fatal_ 'caught signal SIGQUIT'" 3 +# Ignore further SIGPIPE in the trap code. This is required to avoid +# a very weird issue with some shells, at least when the execution of +# the automake testsuite is driven by the 'prove' utility: if prove +# (or the make process that has spawned it) gets interrupted with +# Ctrl-C, the shell might go in a loop, continually getting a SIGPIPE, +# sometimes finally dumping core, other times hanging indefinitely. +# See also Test::Harness bug [rt.cpan.org #70855], archived at +# +trap "trap '' 13; fatal_ 'caught signal SIGPIPE'" 13 # Create and populate the temporary directory, if and as required. if test x"$am_create_testdir" = x"no"; then -- cgit v1.2.1 From f974da70780271a64295ad87dc92f096b90e9908 Mon Sep 17 00:00:00 2001 From: Stefano Lattarini Date: Mon, 23 Apr 2012 19:03:33 +0200 Subject: tests: fix a spurious failure with dash The dash shell, at least version 0.5.5.1, doesn't always bail out with a syntax error when a stray "fi" in encountered: $ dash -c ":; fi"; echo stat = $? stat = 0 See also the relevant bug report: This behaviour was causing a spurious error in our testsuite. Fix it. * t/self-check-exit.tap: Use a stray parentheses rather than a stray 'fi' to trigger a syntax error. Signed-off-by: Stefano Lattarini --- t/self-check-exit.tap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/self-check-exit.tap b/t/self-check-exit.tap index 1d3c0202b..0ad5651a1 100755 --- a/t/self-check-exit.tap +++ b/t/self-check-exit.tap @@ -97,7 +97,7 @@ command_ok_ "permission denied" test $? -gt 0 : Syntax errors in the test code. $AM_TEST_RUNNER_SHELL -c "$init; if :; then" "$dummy_test_script" command_ok_ "syntax error 1" test $? -gt 0 -$AM_TEST_RUNNER_SHELL -c "$init; fi" "$dummy_test_script" +$AM_TEST_RUNNER_SHELL -c "$init; true ( true )" "$dummy_test_script" command_ok_ "syntax error 2" test $? -gt 0 : -- cgit v1.2.1