automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[FYI] {tap-testsuite-work} testsuite: use custom TAP diagnostic in our o


From: Stefano Lattarini
Subject: [FYI] {tap-testsuite-work} testsuite: use custom TAP diagnostic in our own tests
Date: Fri, 5 Aug 2011 23:41:32 +0200
User-agent: KMail/1.13.3 (Linux/2.6.30-2-686; KDE/4.4.4; i686; ; )

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              |   18 ++++++++++++++++++
 tests/Makefile.am      |    9 +++++++++
 tests/Makefile.in      |    3 ++-
 tests/add-missing.tap  |   17 ++++++++++-------
 tests/defs             |   27 ++++-----------------------
 tests/tap-functions.sh |   10 ++++++++--
 6 files changed, 51 insertions(+), 33 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b2b45e3..e8756c6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
 2011-08-05  Stefano Lattarini  <address@hidden>
 
+       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  <address@hidden>
+
        tap: fix typo in TAP driver version message
        * lib/tap-driver (anonymous subroutine printing the script version
        message): Add missing trailing newline to the version message.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index eca524b..425112b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -19,6 +19,15 @@
 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
diff --git a/tests/Makefile.in b/tests/Makefile.in
index 5286f6d..d371452 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -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 \
diff --git a/tests/add-missing.tap b/tests/add-missing.tap
index 809b30f..4c6a624 100755
--- a/tests/add-missing.tap
+++ b/tests/add-missing.tap
@@ -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
diff --git a/tests/defs b/tests/defs
index 3ce92fd..c468d5f 100644
--- a/tests/defs
+++ b/tests/defs
@@ -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
diff --git a/tests/tap-functions.sh b/tests/tap-functions.sh
index 0104d39..d87a32c 100644
--- a/tests/tap-functions.sh
+++ b/tests/tap-functions.sh
@@ -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).
-- 
1.7.2.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]