+2011-04-23 Jim Meyering <meyering@redhat.com>
+ Stefano Lattarini <stefano.lattarini@gmail.com>
+
+ test defs: new subroutines for test skipping/failing
+ * tests/defs.in (Exit): Move definition of this function earlier.
+ (warn_, skip_, fail_, framework_failure_): New functions, inspired
+ to the homonyms in gnulib's tests/init.sh.
+ ($stderr_fileno_): New global variable, used by the new functions
+ above.
+ * tests/README: Updated.
+ From a suggestion by Ralf Wildenhues.
+
2011-04-23 Stefano Lattarini <stefano.lattarini@gmail.com>
tests: fix typo (copy & paste blunder) in heading comment
Include ./defs in every test script (see existing tests for examples
of how to do this).
+ Use the `skip_' function to skip tests, with a meaningful message if
+ possible. Where convenient, use the `warn_' function to print generic
+ warnings, and the `fail_' function for test failures. Finally, you may
+ use the `framework_fail_' function for hard errors.
+
For tests that use the `parallel-tests' Automake option, set the shell
variable `parallel_tests' to "yes" before including ./defs. Also,
use for them a name that ends in `-p.test' and does not clash with any
# (See note about `export' in the Autoconf manual.)
export PATH
+# We use a trap below for cleanup. This requires us to go through
+# hoops to get the right exit status transported through the signal.
+# 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 putting, say:
+# stderr_fileno_=9; export stderr_fileno_; exec 9>&2;
+# in the definition of AM_TESTS_ENVIRONMENT.
+# 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}
+
+# Copied from Gnulib's `tests/init.sh'.
+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; }
+
for tool in : $required
do
# Check that each required tool is present.
;;
esac
-# We use a trap below for cleanup. This requires us to go through
-# hoops to get the right exit status transported through the signal.
-# 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
-}
-
curdir=`pwd`
testSubDir=$me.dir
test ! -d $testSubDir || {