tests: sanitize 'unset' usages
authorStefano Lattarini <stefano.lattarini@gmail.com>
Fri, 17 May 2013 11:45:44 +0000 (13:45 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Fri, 17 May 2013 13:40:35 +0000 (15:40 +0200)
commit84e12c32964ef8454be946b4b2eeb46766ca9add
treeb397fb95a2b599f73e9fc19e228178881c0c3ce9
parent176d229b5136806a6f34d18f08dfc986e6c26c76
tests: sanitize 'unset' usages

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>
36 files changed:
t/aclocal-macrodir.tap
t/aclocal-macrodirs.tap
t/auxdir-autodetect.sh
t/ax/am-test-lib.sh
t/ax/test-lib.sh
t/check-tests-in-builddir.sh
t/dist-formats.tap
t/distcheck-configure-flags-am.sh
t/distcheck-configure-flags.sh
t/java-empty-classpath.sh
t/javaflags.sh
t/lflags.sh
t/lflags2.sh
t/lisp-flags.sh
t/lisp6.sh
t/missing-auxfile-stops-makefiles-creation.sh
t/parallel-am.sh
t/parallel-am2.sh
t/parallel-am3.sh
t/parallel-tests-log-override-recheck.sh
t/pkg-config-macros.sh
t/python-missing.sh
t/python-too-old.sh
t/python11.sh
t/self-check-dir.tap
t/self-check-report.sh
t/self-check-seq.tap
t/silent-configsite.sh
t/suffix6c.sh
t/tar-override.sh
t/tests-environment-and-log-compiler.sh
t/vala-configure.sh
t/werror3.sh
t/yflags-cmdline-override.sh
t/yflags.sh
t/yflags2.sh