changeset 13154:6a5baf77920b

init.sh: make it easier for a test script to write to the tty, ... when using automake's parallel-tests mode. * tests/init.sh (stderr_fileno_): Define overridable variable. (warn_): New function, to use it. (fail_, skip_, framework_failure_): Use warn_.
author Jim Meyering <meyering@redhat.com>
date Mon, 05 Apr 2010 10:01:07 +0200
parents 5566a3e85a6d
children 84dfb14c78a7
files ChangeLog tests/init.sh
diffstat 2 files changed, 20 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2010-04-05  Jim Meyering  <meyering@redhat.com>
+
+	init.sh: make it easier for a test script to write to the tty, ...
+	when using automake's parallel-tests mode.
+	* tests/init.sh (stderr_fileno_): Define overridable variable.
+	(warn_): New function, to use it.
+	(fail_, skip_, framework_failure_): Use warn_.
+
 2010-04-04  Bruno Haible  <bruno@clisp.org>
 
 	btowc: Avoid warning.
--- a/tests/init.sh
+++ b/tests/init.sh
@@ -96,8 +96,18 @@
 # sh inside this function.
 Exit () { set +e; (exit $1); exit $1; }
 
-fail_() { echo "$ME_: failed test: $@" 1>&2; Exit 1; }
-skip_() { echo "$ME_: skipped test: $@" 1>&2; Exit 77; }
+# 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