+2011-08-05 Stefano Lattarini <stefano.lattarini@gmail.com>
+
+ testsuite: use custom TAP diagnostic in our own tests
+ This change allow us to easily and transparently avoid spurious
+ TAP diagnostic in our own testsuite, with the help of the new
+ `--diagnostic-string' option of our TAP test driver.
+ * tests/Makefile.am (TAP_LOG_DRIVER_FLAGS): Also pass option
+ `--diagnostic-string' with value `#%#' (necessarily obtained
+ through some shell indirections).
+ * tests/tap-functions.sh (diag_): Assume that the string denoting
+ TAP diagnostic is stored in the `$diag_string_' variable. Update
+ comments.
+ ($diag_string_): Initialize to "#".
+ * tests/defs ($diag_string_): Re-define to "#%#".
+ (show_): Remove, it's obsolete now.
+ * add-missing.tap: Don't use `show_' anymore to avoid spurious
+ TAP diagnostic; `cat' should suffice now.
+
2011-08-05 Stefano Lattarini <stefano.lattarini@gmail.com>
tap: fix typo in TAP driver version message
TEST_EXTENSIONS = .test .tap
TAP_LOG_DRIVER = $(PERL) $(top_srcdir)/lib/tap-driver
TAP_LOG_DRIVER_FLAGS = --merge --comments
+## Avoid spurious TAP diagnostic. We use an awful indirection with a
+## shell command substitution here, since the string needs to contain
+## `#' characters, and these can't be escaped portably in a make macro
+## definition.
+## FIXME: this is quite inefficient though, as it adds one extra fork
+## FIXME: per TAP test script; this is OK for the moment, since we have
+## FIXME: few such scripts, but might become an issue in the future.
+## Keep this in sync with the definition of $diag_string_ in tests/defs.
+TAP_LOG_DRIVER_FLAGS += --diagnostic-string `printf '\043%%\043\n'`
MAINTAINERCLEANFILES =
EXTRA_DIST = ChangeLog-old
top_srcdir = @top_srcdir@
TEST_EXTENSIONS = .test .tap .ptest .instspc .depmod .shtst
TAP_LOG_DRIVER = $(PERL) $(top_srcdir)/lib/tap-driver
-TAP_LOG_DRIVER_FLAGS = --merge --comments
+TAP_LOG_DRIVER_FLAGS = --merge --comments --diagnostic-string `printf \
+ '\043%%\043\n'`
MAINTAINERCLEANFILES =
EXTRA_DIST = ChangeLog-old gen-parallel-tests parallel-tests.sh \
instspc-tests.sh depmod-tests.sh gen-config-shell-tests \
rm -rf install-sh missing depcomp configure.in autom4te*.cache
mv aclocal.m4 aclocal.stub
-show_ configure.stub
-show_ aclocal.stub
+cat configure.stub
+cat aclocal.stub
# This is hacky and ugly and complex, but allow us to organize our tests
# below in a more "declarative fashion". All in all, a good trade-off.
if test $run_aclocal = yes; then
if $ACLOCAL; then
ok_ "[$name] aclocal.m4 rebuilt"
- show_ aclocal.m4
+ echo == aclocal.m4 ==
+ cat aclocal.m4
else
not_ok_ "[$name] aclocal failure, aclocal.m4 not rebuilt"
fi
else
cp ../aclocal.stub aclocal.m4
fi
- show_ Makefile.am
- show_ configure.in
+ echo == Makefile.am ==
+ cat Makefile.am
+ echo == configure.in ==
+ cat configure.in
echo Expected files: $files
mkdir "$build_aux"
cd ..
all_files="install-sh missing $files"
for f in $all_files; do echo $f; done | sort | uniq > files.exp
(cd $build_aux && ls) | sort > files.got
- show_ files.exp
- show_ files.got
+ cat files.exp
+ cat files.got
command_ok_ \
"$pfx all and only expected files installed" \
$am_diff files.exp files.got
fi
unset funcs_file_
+# Avoid spurious TAP diagnostic. Keep this in sync with the definition
+# of $(TAP_LOG_DRIVER_FLAGS) in `tests/Makefile.am'.
+diag_string_="#%#"
+
# cross_compiling
# ---------------
# Tell whether we are cross-compiling. This is especially useful to skip
test -z "$is_newest_files"
}
-# show_ [--prepend STRING] [FILES...]
-# ----------------------------
-# Show the content of each of the given files that is not empty,
-# prepending every one of its lines with the given STRING (defaulting
-# to " | "). STRING cannot contain the "#" or "\" character.
-# This function is not just eye-candy and syntactic sugar: in tests
-# that use the TAP protocols, a line beginning with a "#" character
-# would be interpreted by the TAP driver as a diagnostic line, and
-# possibly displayed on console (with the risk of cluttering precious
-# screen space with noise).
-show_ ()
-{
- set +x
- p_=" | "
- case $1 in -p|--prepend) p_=$2; shift 2;; esac
- for f_ in ${1+"$@"}; do
- test -s "$f_" || { echo "== $f_ is empty"; continue; }
- echo "== $f_ =="
- sed "s#^#$p_#" "$f_"
- done
- set -x
-}
-
# AUTOMAKE_run [-e STATUS] [-d DESCRIPTION] [--] [AUTOMAKE-ARGS...]
# -----------------------------------------------------------------
# Run automake with AUTOMAKE-ARGS, and fail if it doesn't exit with
# diag_ [EXPLANATION]
# ------------------
-# Report the given text as TAP diagnostic.
+# Report the given text as TAP diagnostic. Assumes the string denoting
+# TAP diagnostic lines is stored in the `$diag_string_' variable; this is
+# done to allow better interplay with TAP drivers that allow such a string
+# to be configured.
diag_ ()
{
- test $# -eq 0 || echo "# $*"
+ test $# -eq 0 || echo "$diag_string_ $*"
}
+# Used by the `diag_' function above. User-overridable.
+diag_string_="#"
+
# warn_ [EXPLANATION]
# ------------------
# Give a warning (using TAP diagnostic).