[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 26/32] tests: move sanitization and "Bournification" in the gener
From: |
Stefano Lattarini |
Subject: |
[PATCH 26/32] tests: move sanitization and "Bournification" in the generic test lib |
Date: |
Thu, 26 Jul 2012 14:04:52 +0200 |
* t/ax/test-defs.sh: From here ...
* t/ax/test-lib.sh: ... to here. Also move the initialization of
'$argv0' and '$me'.
Signed-off-by: Stefano Lattarini <address@hidden>
---
t/ax/test-defs.in | 39 ---------------------------------------
t/ax/test-lib.sh | 42 +++++++++++++++++++++++++++++++++++++++++-
2 files changed, 41 insertions(+), 40 deletions(-)
diff --git a/t/ax/test-defs.in b/t/ax/test-defs.in
index 9a9e632..7a03f92 100644
--- a/t/ax/test-defs.in
+++ b/t/ax/test-defs.in
@@ -22,45 +22,6 @@
# - Multiple inclusions of this file should be idempotent.
# - This code has to be 'set -e' clean.
-# CDPATH is evil if used in non-interactive scripts (and even more
-# evil if exported in the environment).
-CDPATH=; unset CDPATH
-
-# Be more Bourne compatible.
-# (Snippet inspired to configure's initialization in Autoconf 2.64)
-DUALCASE=1; export DUALCASE # for MKS sh
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
- emulate sh
- NULLCMD=:
- setopt NO_GLOB_SUBST
- # If Zsh is not started directly in POSIX-compatibility mode, it has some
- # incompatibilities in the handling of $0 that conflict with our usage;
- # i.e., $0 inside a file sourced with the '.' builtin is temporarily set
- # to the name of the sourced file. Work around that.
- # Note that a bug in some versions of Zsh prevents us from resetting $0
- # in a sourced script, so the use of $argv0. For more info see:
- # <http://www.zsh.org/mla/workers/2009/msg01140.html>
- # The apparently useless 'eval' here is needed by at least dash 0.5.2,
- # to prevent it from bailing out with an error like:
- # "Syntax error: Bad substitution".
- eval 'argv0=${functrace[-1]%:*}' && test -f "$argv0" || {
- echo "Cannot determine the path of running test script." >&2
- echo "Your Zsh (version $ZSH_VERSION) is probably too old." >&2
- exit 99
- }
-else
- argv0=$0
- # Avoid command substitution failure, for Tru64 sh -e and instspc*.test.
- case `(set -o) 2>/dev/null || :` in *posix*) set -o posix;; esac
-fi
-
-# The name of the current test (without the '.sh' or '.tap' suffix).
-me=${argv0##*/} # Strip all directory components.
-case $me in # Strip test suffix.
- *.tap) me=${me%.tap};;
- *.sh) me=${me%.sh} ;;
- esac
-
# Check that the environment is properly sanitized.
# Having variables exported to the empty string is OK, since our code
# treats such variables as if they were unset.
diff --git a/t/ax/test-lib.sh b/t/ax/test-lib.sh
index f711f1e..60ffd98 100644
--- a/t/ax/test-lib.sh
+++ b/t/ax/test-lib.sh
@@ -19,6 +19,39 @@
### IMPORTANT NOTE: keep this file 'set -e' clean. ###
########################################################
+# CDPATH is evil if used in non-interactive scripts (and even more
+# evil if exported in the environment).
+CDPATH=; unset CDPATH
+
+# Be more Bourne compatible.
+# (Snippet inspired to configure's initialization in Autoconf 2.64)
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ setopt NO_GLOB_SUBST
+ # If Zsh is not started directly in POSIX-compatibility mode, it has some
+ # incompatibilities in the handling of $0 that conflict with our usage;
+ # i.e., $0 inside a file sourced with the '.' builtin is temporarily set
+ # to the name of the sourced file. Work around that.
+ # Note that a bug in some versions of Zsh prevents us from resetting $0
+ # in a sourced script, so the use of $argv0. For more info see:
+ # <http://www.zsh.org/mla/workers/2009/msg01140.html>
+ # The apparently useless 'eval' here is needed by at least dash 0.5.2,
+ # to prevent it from bailing out with an error like:
+ # "Syntax error: Bad substitution".
+ eval 'argv0=${functrace[-1]%:*}' && test -f "$argv0" || {
+ echo "Cannot determine the path of running test script." >&2
+ echo "Your Zsh (version $ZSH_VERSION) is probably too old." >&2
+ exit 99
+ }
+else
+ argv0=$0
+ # Avoid command substitution failure, for it might cause problems with
+ # "set -e" on some shells.
+ case `(set -o) 2>/dev/null || :` in *posix*) set -o posix;; esac
+fi
+
# A single whitespace character.
sp=' '
# A tabulation character.
@@ -31,7 +64,14 @@ nl='
# is defined initially, so that saving and restoring $IFS works.
IFS=$sp$tab$nl
-# Source extra configuration.
+# The name of the current test (without the '.sh' or '.tap' suffix).
+me=${argv0##*/} # Strip all directory components.
+case $me in # Strip test suffix.
+ *.tap) me=${me%.tap};;
+ *.sh) me=${me%.sh} ;;
+ esac
+
+# Source extra package-specific configuration.
. test-defs.sh
# And fail hard if something went wrong.
test $? -eq 0 || exit 99
--
1.7.12.rc0
- [PATCH 13/32] test init: refactor: new function 'require_tool', (continued)
- [PATCH 13/32] test init: refactor: new function 'require_tool', Stefano Lattarini, 2012/07/26
- [PATCH 17/32] test init: refactor: new function 'am_set_exit_traps', Stefano Lattarini, 2012/07/26
- [PATCH 11/32] tests: simplify sourcing of helper shell files, Stefano Lattarini, 2012/07/26
- [PATCH 19/32] test init: refactor: move displaying of debugging info later, Stefano Lattarini, 2012/07/26
- [PATCH 16/32] configure: testsuite shell set exit traps in shell functions, Stefano Lattarini, 2012/07/26
- [PATCH 21/32] test setup: merge definitions of function for simple tests, Stefano Lattarini, 2012/07/26
- [PATCH 23/32] tests: split test libs into "generic" and "automake-specific", Stefano Lattarini, 2012/07/26
- [PATCH 27/32] configure: testsuite shell can return early from "dot-sourced" files, Stefano Lattarini, 2012/07/26
- [PATCH 25/32] tests: source test defs in the generic test lib, Stefano Lattarini, 2012/07/26
- [PATCH 22/32] test setup: move actual calling of testsuite setup in ./defs, Stefano Lattarini, 2012/07/26
- [PATCH 26/32] tests: move sanitization and "Bournification" in the generic test lib,
Stefano Lattarini <=
- [PATCH 24/32] test defs: no need to re-add $srcdir/t/ax to $PATH, Stefano Lattarini, 2012/07/26
- [PATCH 20/32] test init: refactor: new function 'am_test_setup', Stefano Lattarini, 2012/07/26
- [PATCH 28/32] tests: protect test libs against multiple inclusion, Stefano Lattarini, 2012/07/26
- [PATCH 29/32] tests: "am_using_tap=yes" -> "am_test_protocol=tap", Stefano Lattarini, 2012/07/26
- [PATCH 31/32] runtest: sanitize test environment, Stefano Lattarini, 2012/07/26
- [PATCH 30/32] tests: remove an obsolescent self test, Stefano Lattarini, 2012/07/26
- [PATCH 32/32] tests: never source test-defs.sh directly, source test-lib.sh instead, Stefano Lattarini, 2012/07/26
- [PATCH 33/32] maintcheck: fixup list of files in $(xdefs), Stefano Lattarini, 2012/07/26
- Re: [PATCH 00/32] {maint} Several testsuite refactorings, Stefano Lattarini, 2012/07/26