In some shells (e.g., Solaris 10 /bin/ksh, or NetBSD 5.1 /bin/sh),
"unset VAR" returns a non-zero exit status in case the VAR variable
is already unset. This doesn't interact well with our usage of
"set -e" in the testsuite. So far, we've avoided spurious failures
by either explicitly ignoring the exit status from unset:
unset VAR || :
or explicitly ensuring that a variable is set, before trying to
unset it:
VAR=; unset VAR
But we can do better, by aliasing the 'unset' command to a custom
function that will take care of these details for us. This will
avoid us annoying spurious failures in the future, failures that
have already bitten us too much times. For an example, refer to
commit '
v1.12.2-88-g5b1dae5' of 2012-08-05 (tests: avoid tons of
spurious failures on NetBSD).
* t/ax/test-lib.sh (_am_unset): New function.
(unset): New alias to it.
(_am_exit): Adjust comments.
* t/ax/am-test-lib.sh: No need to temporary disable the 'errexit'
shell flag when unsetting variables that are potentially already
unset.
(am_process_requirements): Adjust to remove a now-useless
workaround related to unset.
* t/aclocal-macrodir.tap: Likewise.
* t/aclocal-macrodirs.tap: Likewise.
* t/auxdir-autodetect.sh: Likewise.
* t/ax/am-test-lib.sh: Likewise.
* t/ax/test-lib.sh: Likewise.
* t/check-tests-in-builddir.sh: Likewise.
* t/dist-formats.tap: Likewise.
* t/distcheck-configure-flags-am.sh: Likewise.
* t/distcheck-configure-flags.sh: Likewise.
* t/java-empty-classpath.sh: Likewise.
* t/javaflags.sh: Likewise.
* t/lflags.sh: Likewise.
* t/lflags2.sh: Likewise.
* t/lisp-flags.sh: Likewise.
* t/lisp6.sh: Likewise.
* t/missing-auxfile-stops-makefiles-creation.sh: Likewise.
* t/parallel-am.sh: Likewise.
* t/parallel-am2.sh: Likewise.
* t/parallel-am3.sh: Likewise.
* t/parallel-tests-log-override-recheck.sh: Likewise.
* t/pkg-config-macros.sh: Likewise.
* t/python-missing.sh: Likewise.
* t/python-too-old.sh: Likewise.
* t/python11.sh: Likewise.
* t/self-check-dir.tap: Likewise.
* t/self-check-report.sh: Likewise.
* t/self-check-seq.tap: Likewise.
* t/silent-configsite.sh: Likewise.
* t/suffix6c.sh: Likewise.
* t/tar-override.sh: Likewise.
* t/tests-environment-and-log-compiler.sh: Likewise.
* t/vala-configure.sh: Likewise.
* t/werror3.sh: Likewise.
* t/yflags-cmdline-override.sh: Likewise.
* t/yflags.sh: Likewise.
* t/yflags2.sh: Likewise.
Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
plan_ 7
ocwd=$(pwd) || fatal_ "getting current working directory"
-ACLOCAL_PATH=; unset ACLOCAL_PATH
+unset ACLOCAL_PATH
#
# General utility functions and variables.
plan_ 15
ocwd=$(pwd) || fatal_ "getting current working directory"
-ACLOCAL_PATH=; unset ACLOCAL_PATH
+unset ACLOCAL_PATH
#
# General utility functions and variables.
nil=__no_such_program
-unset NONESUCH || :
+unset NONESUCH
cat >>configure.ac << END
AM_MISSING_PROG([NONESUCH],[$nil])
## 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-related 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
done
unset pfx
-# Re-enable, it had been temporarily disabled above.
-set -e
-
# cross_compiling
# ---------------
# Tell whether we are cross-compiling. This is especially useful to skip
*" $am_tool"*) . ./t/$am_tool-macros.dir/get.sh;;
esac
done
- am_tool=; unset am_tool
+ unset am_tool
}
## ---------------------------------------------------------------- ##
set +e
# See comments in the exit trap for the reason we do this.
test 77 = $1 && am__test_skipped=yes
- # Spurious escaping to ensure we do not call our 'exit' alias.
+ # Extra escaping to ensure we do not call our 'exit' alias.
(\exit $1); \exit $1
}
# Avoid interferences from the environment
# just inside a function definition. Weird, but real.
alias exit=_am_exit
+# In some shells (e.g., Solaris 10 /bin/ksh, or NetBSD 5.1 /bin/sh),
+# "unset VAR" returns a non-zero exit status in case the VAR variable
+# is already unset. This doesn't interact well with our usage of
+# "set -e" in the testsuite. This function and the alias below help
+# to work around the issue.
+_am_unset ()
+{
+ for _am_v
+ do
+ # Extra escaping (here and below) to ensure we do not call our
+ # 'unset' alias.
+ eval ${_am_v}=dummy && \unset ${_am_v} || exit 1
+ done
+ \unset _am_v
+}
+alias unset=_am_unset
+
## ------------------------------------ ##
## General testsuite shell functions. ##
## ------------------------------------ ##
END
chmod a+x foo.test
-unset FOO_EXIT_STATUS || :
+unset FOO_EXIT_STATUS
$ACLOCAL
$AUTOCONF
ocwd=$(pwd) || fatal_ "getting current working directory"
-TAR='' && unset TAR
+unset TAR
# Create common aclocal.m4 file, for later tests.
mkdir setup \
AC_OUTPUT
END
-unset sentence || :
+unset sentence
cat > Makefile.am << 'END'
AM_DISTCHECK_CONFIGURE_FLAGS = $(dc_flags1) $(dc_flags2)
AC_OUTPUT
END
-unset sentence || :
+unset sentence
: > Makefile.am
$AUTOMAKE
./configure
-unset CLASSPATH || :
+unset CLASSPATH
$MAKE
$MAKE clean
$MAKE
$MAKE clean
-unset CLASSPATH || :
+unset CLASSPATH
$MAKE distcheck
:
# Remove JAVAC from the environment, so that it won't interfere
# with 'make -e' below.
-unset JAVAC || :
+unset JAVAC
cat >> configure.ac <<'END'
AC_PROG_CC
# Remove Lex from the environment, so that it won't interfere
# with 'make -e' below.
-unset LEX || :
+unset LEX
cat >> configure.ac <<'END'
AC_SUBST([CC], [false])
# Remove Lex from the environment, so that it won't interfere
# with 'make -e' below.
-unset LEX || :
+unset LEX
cat >> configure.ac <<'END'
AC_SUBST([CXX], [false])
# Don't get fooled when running as an Emacs subprocess. This is
# for the benefit of the "make -e" invocation below.
-EMACS=; unset EMACS
+unset EMACS
cat > Makefile.am << 'EOF'
lisp_LISP = foo.el
EOF
# Avoid possible spurious influences from the environment.
-want_two=; unset want_two
+unset want_two
echo "(provide 'am-one)" > am-one.el
echo "(require 'am-one)" > am-two.el
$ACLOCAL
-unset AUTOMAKE_JOBS || :
+unset AUTOMAKE_JOBS
AUTOMAKE_fails
ls -l Makefile.in */Makefile.in || : # For debugging.
# Further, automake output should be stable.
# Generate expected output using the non-threaded code.
-unset AUTOMAKE_JOBS || :
+unset AUTOMAKE_JOBS
AUTOMAKE_run --add-missing
mv stderr expected
Makefile_ins=$(find . -name Makefile.in)
# Thus we install the auxiliary files in a prior step.
# Generate expected output using non-threaded code.
-unset AUTOMAKE_JOBS || :
+unset AUTOMAKE_JOBS
rm -f install-sh missing depcomp
AUTOMAKE_fails --add-missing
mv stderr expected
$ACLOCAL
# Generate expected output using the non-threaded code.
-unset AUTOMAKE_JOBS || :
+unset AUTOMAKE_JOBS
AUTOMAKE_run --add-missing
mv stderr expected
mv Makefile.in Makefile.in.exp
chmod a+x *.test
-unset BAZ_EXIT_STATUS || :
+unset BAZ_EXIT_STATUS
$ACLOCAL
$AUTOCONF
echo "skip_all_ \"pkg-config m4 macros not found\"" >> get.sh
fi
-ACLOCAL_PATH=; unset ACLOCAL_PATH
+unset ACLOCAL_PATH
. ./get.sh
$ACLOCAL --force -I m4 || cat >> get.sh <<'END'
# An actual python is *not* required in this test.
. test-init.sh
-PYTHON=; unset PYTHON
+unset PYTHON
cat > configure.ac <<END
AC_INIT([$me], [1.0])
}
saved_PYTHON=$PYTHON; export saved_PYTHON
-PYTHON=; unset PYTHON
+unset PYTHON
cat > configure.ac <<END
AC_INIT([$me], [1.0])
. test-init.sh
# We don't want to allow user overrides in this test.
-PYTHON=; unset PYTHON
+unset PYTHON
cat >>configure.ac <<'EOF'
m4_define([_AM_PYTHON_INTERPRETER_LIST], [IShouldNotExist1 IShouldNotExist2])
plan_ 5
-keep_testdirs=; unset keep_testdirs
+unset keep_testdirs
# This needs to be consistent with what $AM_TEST_RUNNER_SHELL
# deems to be the current working directory.
# Test subroutines to report warnings, and to signal failures, skips
# and hard errors.
-unset stderr_fileno_ || :
+unset stderr_fileno_
am_create_testdir=empty
. test-init.sh
plan_ 14
-unset stderr_fileno_ || :
+unset stderr_fileno_
check_work ()
{
test x'$(AM_DEFAULT_VERBOSITY)' = x'1'
EOF
-unset enable_silent_rules || :
+unset enable_silent_rules
: 'No explicit default in configure.ac, enable by default in config.site'
AC_OUTPUT
END
-unset OBJEXT || :
+unset OBJEXT
cat > Makefile.am << 'END'
SUFFIXES = .zoo .o .obj .@OBJEXT@
clean_temp
-TAR=; unset TAR
+unset TAR
# Creative use of eval to pacify maintainer checks.
eval \$'MAKE dist "TAR=./am--tar mu"'
test -f $distdir.tar.gz
AC_OUTPUT
END
-unset v0 v1 v2 v3 v4 || :
+unset v0 v1 v2 v3 v4
cat > Makefile.am << 'END'
TESTS_ENVIRONMENT = am__f3 () { echo 3; }; v0='$(srcdir)' v1=1; :;
PATH=$(pwd)/bin$PATH_SEPARATOR$PATH; export PATH
# Avoid interferences from the environment.
-VALAC= vala_version=; unset VALAC vala_version
+unset VALAC vala_version
$ACLOCAL
$AUTOMAKE -a
$ACLOCAL
# The issue would not manifest with threaded execution.
-unset AUTOMAKE_JOBS || :
+unset AUTOMAKE_JOBS
AUTOMAKE_run -Wno-error
grep 'VAR multiply defined' stderr
required='cc yacc'
. test-init.sh
-unset YFLAGS || :
+unset YFLAGS
cat >> configure.ac <<'END'
AC_PROG_CC
# Remove Yacc from the environment, so that it won't interfere
# with 'make -e' below.
-unset YACC || :
+unset YACC
cat >> configure.ac <<'END'
AC_SUBST([CC], [false])
# Remove Yacc from the environment, so that it won't interfere
# with 'make -e' below.
-unset YACC || :
+unset YACC
cat >> configure.ac <<'END'
AC_SUBST([CXX], [false])