* 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 <stefano.lattar...@gmail.com> --- 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