]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
testsuite: use custom TAP diagnostic in our own tests
authorStefano Lattarini <stefano.lattarini@gmail.com>
Fri, 5 Aug 2011 20:58:03 +0000 (22:58 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Fri, 5 Aug 2011 21:36:15 +0000 (23:36 +0200)
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.

ChangeLog
tests/Makefile.am
tests/Makefile.in
tests/add-missing.tap
tests/defs
tests/tap-functions.sh

index b2b45e33a995726513f713bf3e0ead55f9e17f7c..e8756c61b94a173ac1e15104bb1df7b059b9ace2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+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
index eca524b77e46d6e34f91c4163f8b00ba4965bebb..425112b92fd7b864be6016b5f60af9120bfdb2c3 100644 (file)
 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
index 5286f6dccda659495978c8d2e9092f994d657e9a..d371452f2d4aa87c181e39ca81d6e8621d218443 100644 (file)
@@ -300,7 +300,8 @@ top_builddir = @top_builddir@
 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 \
index 809b30f9f9a59d37eaaba9057ee065c98413236b..4c6a6248c3680040cc35c74ad9f1397fca84c07a 100755 (executable)
@@ -54,8 +54,8 @@ $ACLOCAL || framework_failure_ "cannot pre-compute aclocal.m4"
 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.
@@ -111,15 +111,18 @@ check_ ()
   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 ..
@@ -173,8 +176,8 @@ check_ ()
     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
index 3ce92fd487e2e1cf08db25b0934ad5f9182b9a25..c468d5fa09359c684f28acf74f4ffd18f1bb57da 100644 (file)
@@ -183,6 +183,10 @@ else
 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
@@ -202,29 +206,6 @@ is_newest ()
   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
index 0104d39277dc0edadadfa6b4e433891f9e310558..d87a32c00e7eecac9037a4bc5745a3da27adb7fb 100644 (file)
@@ -63,12 +63,18 @@ have_tap_plan_=no
 
 # 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).