[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[FYI 5/7] {tap-testsuite-work} test defs: really make them "set -e" clea
From: |
Stefano Lattarini |
Subject: |
[FYI 5/7] {tap-testsuite-work} test defs: really make them "set -e" clean |
Date: |
Tue, 9 Aug 2011 15:35:33 +0200 |
Motivated by a spurious failure of test `instsh3-w.shtst' on
Solaris 10.
* tests/defs: Make really "set -e" clean, to avoid spurious
failures in case this file is sourced by a test script that has
already set the `errexit' flag. To be sure we don't regress,
move the `set -e' call much earlier, and make the comment telling
about the expected "set -e" cleanliness more loud and outstanding.
---
ChangeLog | 11 +++++++++++
tests/defs | 39 ++++++++++++++++++++++++---------------
2 files changed, 35 insertions(+), 15 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 97b0ae5..0cbdc9e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2011-08-09 Stefano Lattarini <address@hidden>
+ test defs: really make them "set -e" clean
+ Motivated by a spurious failure of test `instsh3-w.shtst' on
+ Solaris 10.
+ * tests/defs: Make really "set -e" clean, to avoid spurious
+ failures in case this file is sourced by a test script that has
+ already set the `errexit' flag. To be sure we don't regress,
+ move the `set -e' call much earlier, and make the comment telling
+ about the expected "set -e" cleanliness more loud and outstanding.
+
+2011-08-09 Stefano Lattarini <address@hidden>
+
self tests: register an expected failures with Solaris /bin/sh
Solaris 10 /bin/sh erroneously exit with success right away when
the following three conditions are met at the same time:
diff --git a/tests/defs b/tests/defs
index 0ba984e..cf9b86a 100644
--- a/tests/defs
+++ b/tests/defs
@@ -17,18 +17,18 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+########################################################
+### IMPORTANT NOTE: keep this file 'set -e' clean. ###
+########################################################
-# IMPORTANT NOTE: This file should execute correctly with any system's
-# /bin/sh shell, and not only with configure-time detected $CONFIG_SHELL,
-# until differently and explicitly specified.
-
+# NOTE: This file should execute correctly with any system's /bin/sh
+# shell, and not only with configure-time detected $CONFIG_SHELL,
+# *until differently and explicitly specified*.
## -------------------------------------------------------- ##
## Source static setup and definitions for the testsuite. ##
## -------------------------------------------------------- ##
-# This code needs to be 'set -e' clean.
-
# Ensure we are running from the right directory.
test -f ./defs-static || {
echo "$0: ./defs-static: not found in current directory" >&2
@@ -38,6 +38,9 @@ test -f ./defs-static || {
# Source the shell sanitization and variables' definitions.
. ./defs-static || exit 99
+# Enable the errexit shell flag early.
+set -e
+
# The name of the current test (without the `.test' suffix).
# Test scripts can override it if they need to (but this should
# be done carefully, and *before* including ./defs).
@@ -103,9 +106,10 @@ case ${AM_TESTS_REEXEC-yes} in
*) opts=;;
esac
echo $me: exec $SHELL $opts "$0" "$*"
- exec $SHELL $opts "$0" ${1+"$@"}
- echo "$me: failed to re-execute with $SHELL" >&2
- exit 99
+ exec $SHELL $opts "$0" ${1+"$@"} || {
+ echo "$me: failed to re-execute with $SHELL" >&2
+ exit 99
+ }
;;
esac
@@ -117,6 +121,11 @@ esac
## Environment cleanup. ##
## ---------------------- ##
+# Temporarily disable this, since some shells (e.g., older version
+# of Bash) can return a non-zero exit status upon the when a non-set
+# variable is unset.
+set +e
+
# Unset some MAKE... variables that may cause $MAKE to act like a
# recursively invoked sub-make. Any $MAKE invocation in a test is
# conceptually an independent invocation, not part of the main
@@ -148,6 +157,8 @@ unset TEST_LOGS
unset RECHECK_LOGS
unset VERBOSE
+# Re-enable, it had been temporarily disabled above.
+set -e
## ---------------------------- ##
## Auxiliary shell functions. ##
@@ -610,8 +621,8 @@ do
|| framework_failure_ "creating unwritable file $priv_check_temp"
# Not a useless use of subshell: lesser shells like Solaris /bin/sh
# can exit if a builtin fails.
- (echo foo >> $priv_check_temp)
- overwrite_status=$?
+ overwrite_status=0
+ (echo foo >> $priv_check_temp) || overwrite_status=$?
rm -f $priv_check_temp
if test $overwrite_status -eq 0; then
skip_all_ "cannot drop file write permissions"
@@ -639,8 +650,8 @@ do
|| framework_failure_ "creating unwritable directory $ro_dir_temp"
# Not a useless use of subshell: lesser shells like Solaris /bin/sh
# can exit if a builtin fails.
- (: > $ro_dir_temp/probe)
- create_status=$?
+ create_status=0
+ (: > $ro_dir_temp/probe) || create_status=$?
rm -rf $ro_dir_temp
if test $create_status -eq 0; then
skip_all_ "cannot drop directory write permissions"
@@ -893,6 +904,4 @@ fi
## ---------------- ##
set -x
-set -e
-
pwd
--
1.7.2.3
- [FYI 0/7] {tap-testsuite-work} Some more testsuite patches., Stefano Lattarini, 2011/08/09
- [FYI 1/7] {tap-testsuite-work} test defs: test directory creation more configurable, Stefano Lattarini, 2011/08/09
- [FYI 2/7] {tap-testsuite-work} self tests: some new uses of TAP, few extensions, Stefano Lattarini, 2011/08/09
- [FYI 3/7] {tap-testsuite-work} gitignore: update and improve for the testsuite files, Stefano Lattarini, 2011/08/09
- [FYI 4/7] {tap-testsuite-work} self tests: register an expected failures with Solaris /bin/sh, Stefano Lattarini, 2011/08/09
- [FYI 5/7] {tap-testsuite-work} test defs: really make them "set -e" clean,
Stefano Lattarini <=
- [FYI 6/7] {tap-testsuite-work} test defs: few more sanity checks, Stefano Lattarini, 2011/08/09
- [FYI 7/7] {tap-testsuite-work} self tests: avoid spurious output on console, and related fixlets, Stefano Lattarini, 2011/08/09