X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=tests%2Finit.sh;h=794352673f223c6592260c3352a3a793705c7961;hb=a01b938c7f0c8e406c82d07cb921bf6c3c1e29df;hp=2ad385f2fa236cbdfa9fc5d718a4c12827596279;hpb=cfa7f85bf1b1b1dcb51b27dc615f85e62710c056;p=gnulib.git diff --git a/tests/init.sh b/tests/init.sh index 2ad385f2f..794352673 100644 --- a/tests/init.sh +++ b/tests/init.sh @@ -57,6 +57,28 @@ # 4. Finally # $ exit +ME_=`expr "./$0" : '.*/\(.*\)$'` + +# We use a trap below for cleanup. This requires us to go through +# hoops to get the right exit status transported through the handler. +# So use `Exit STATUS' instead of `exit STATUS' inside of the tests. +# Turn off errexit here so that we don't trip the bug with OSF1/Tru64 +# sh inside this function. +Exit () { set +e; (exit $1); exit $1; } + +# Print warnings (e.g., about skipped and failed tests) to this file number. +# Override by defining to say, 9, in init.cfg, and putting say, +# "export ...ENVVAR_SETTINGS...; exec 9>&2; $(SHELL)" in the definition +# of TESTS_ENVIRONMENT in your tests/Makefile.am file. +# This is useful when using automake's parallel tests mode, to print +# the reason for skip/failure to console, rather than to the .log files. +: ${stderr_fileno_=2} + +warn_() { echo "$@" 1>&$stderr_fileno_; } +fail_() { warn_ "$ME_: failed test: $@"; Exit 1; } +skip_() { warn_ "$ME_: skipped test: $@"; Exit 77; } +framework_failure_() { warn_ "$ME_: set-up failure: $@"; Exit 99; } + # We require $(...) support unconditionally. # We require a few additional shell features only when $EXEEXT is nonempty, # in order to support automatic $EXEEXT emulation: @@ -90,13 +112,17 @@ else # It does not evaluate any of the code after the "unexpected" `('. Thus, # we must run it in a subshell. ( eval "$gl_shell_test_script_" ) > /dev/null 2>&1 - if test $? != 9; then + if test $? = 9; then + : # The current shell is adequate. No re-exec required. + else + # Search for a shell that meets our requirements. for re_shell_ in "${CONFIG_SHELL:-no_shell}" /bin/sh bash dash zsh pdksh fail do test "$re_shell_" = no_shell && continue test "$re_shell_" = fail && skip_ failed to find an adequate shell "$re_shell_" -c "$gl_shell_test_script_" 2>/dev/null - if test $? = 2; then + if test $? = 9; then + # Found an acceptable shell. exec "$re_shell_" "$0" --no-reexec "$@" echo "$ME_: exec failed" 1>&2 exit 127 @@ -114,34 +140,14 @@ test -n "$EXEEXT" && shopt -s expand_aliases : ${MALLOC_PERTURB_=87} export MALLOC_PERTURB_ -# We use a trap below for cleanup. This requires us to go through -# hoops to get the right exit status transported through the handler. -# So use `Exit STATUS' instead of `exit STATUS' inside of the tests. -# Turn off errexit here so that we don't trip the bug with OSF1/Tru64 -# sh inside this function. -Exit () { set +e; (exit $1); exit $1; } - -# Print warnings (e.g., about skipped and failed tests) to this file number. -# Override by defining to say, 9, in init.cfg, and putting say, -# "export ...ENVVAR_SETTINGS...; exec 9>&2; $(SHELL)" in the definition -# of TESTS_ENVIRONMENT in your tests/Makefile.am file. -# This is useful when using automake's parallel tests mode, to print -# the reason for skip/failure to console, rather than to the .log files. -: ${stderr_fileno_=2} - -warn_() { echo "$@" 1>&$stderr_fileno_; } -fail_() { warn_ "$ME_: failed test: $@"; Exit 1; } -skip_() { warn_ "$ME_: skipped test: $@"; Exit 77; } -framework_failure_() { warn_ "$ME_: set-up failure: $@"; Exit 1; } - # This is a stub function that is run upon trap (upon regular exit and # interrupt). Override it with a per-test function, e.g., to unmount # a partition, or to undo any other global state changes. cleanup_() { :; } -if ( diff --version < /dev/null 2>&1 | grep GNU ) 2>&1 > /dev/null; then +if ( diff --version < /dev/null 2>&1 | grep GNU ) > /dev/null 2>&1; then compare() { diff -u "$@"; } -elif ( cmp --version < /dev/null 2>&1 | grep GNU ) 2>&1 > /dev/null; then +elif ( cmp --version < /dev/null 2>&1 | grep GNU ) > /dev/null 2>&1; then compare() { cmp -s "$@"; } else compare() { cmp "$@"; } @@ -243,7 +249,6 @@ setup_() test "$VERBOSE" = yes && set -x initial_cwd_=$PWD - ME_=`expr "./$0" : '.*/\(.*\)$'` pfx_=`testdir_prefix_` test_dir_=`mktempd_ "$initial_cwd_" "$pfx_-$ME_.XXXX"` \