Merge branch 'testsuite-saner-shell' into maint
authorStefano Lattarini <stefano.lattarini@gmail.com>
Mon, 7 May 2012 20:11:28 +0000 (22:11 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Mon, 7 May 2012 20:11:28 +0000 (22:11 +0200)
* testsuite-saner-shell:
  tests: fix a spurious failure with dash
  test defs: fix indentation (cosmetic change)
  tests: remove obsolete uses of $sh_errexit_works
  configure: search a sturdy POSIX shell to be used in the testsuite
  tests: shell running test scripts is now named AM_TEST_RUNNER_SHELL

14 files changed:
Makefile.am
NEWS
configure.ac
defs
defs-static.in
t/self-check-cleanup.tap
t/self-check-dir.tap
t/self-check-env-sanitize.tap
t/self-check-exit.tap
t/self-check-explicit-skips.sh
t/self-check-me.tap
t/self-check-reexec.tap
t/self-check-sanity.sh
t/self-check-tap.sh

index 5b6cee1..27f65e4 100644 (file)
@@ -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/NEWS b/NEWS
index 57af901..d0575e6 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -70,6 +70,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:
index bda0328..7be2554 100644 (file)
@@ -205,25 +205,182 @@ 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
 
-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
+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
+
+    _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
+  AC_MSG_NOTICE([will use $AM_TEST_RUNNER_SHELL as the testsuite shell])
 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'])
-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])
+
+## ---------------------- ##
+##  Create output files.  ##
+## ---------------------- ##
 
 
 ###########################################################################
diff --git a/defs b/defs
index 7e9a554..fcdbb7d 100644 (file)
--- 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.
 
 
 ## ----------------------- ##
@@ -1001,65 +1001,63 @@ 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
-  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
-  # <https://rt.cpan.org/Ticket/Display.html?id=70855>
-  trap "trap '' 13; fatal_ 'caught signal SIGPIPE'" 13
-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
+  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
+# <https://rt.cpan.org/Ticket/Display.html?id=70855>
+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
index a8a17f0..44db309 100644 (file)
@@ -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).
@@ -216,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.
index a56854b..21c6388 100755 (executable)
 
 . ./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
@@ -58,7 +54,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 +76,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 +87,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 +124,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 +132,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 +159,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 +176,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
index 736238c..424367e 100755 (executable)
@@ -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.
index d4e6cdb..bc78186 100755 (executable)
@@ -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"
 }
 
index c866dbc..0ad5651 100755 (executable)
@@ -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,29 +54,18 @@ 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:
     # <http://lists.gnu.org/archive/html/bug-autoconf/2011-09/msg00004.html>
     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.
     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
 
@@ -88,25 +77,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; true ( true )" "$dummy_test_script"
 command_ok_ "syntax error 2" test $? -gt 0
 
 :
index 3e7a77c..7a92671 100755 (executable)
@@ -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`'|" \
@@ -35,22 +33,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
 
 :
index 5c83ee6..cddc9b5 100755 (executable)
@@ -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
 
index 8237c08..7b91008 100755 (executable)
@@ -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]"
 
index 64e489c..8e31afa 100755 (executable)
@@ -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
 
 :
index 6a2d132..d7f788c 100755 (executable)
 
 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