automake-patches
[Top][All Lists]
Advanced

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

[FYI 5/6] {testsuite-work} maintcheck: look for TAP-based tests without


From: Stefano Lattarini
Subject: [FYI 5/6] {testsuite-work} maintcheck: look for TAP-based tests without TAP plan
Date: Sun, 14 Aug 2011 16:37:57 +0200

* Makefile.am (sc_tests_tap_plan): New maintainer check.
(syntax_check_rules): Add it.
* tests/suffix10.tap: Declare a TAP plan.
* tests/add-missing.tap: Likewise.
---
 ChangeLog             |    8 ++++++++
 Makefile.am           |   21 +++++++++++++++++++++
 Makefile.in           |   16 ++++++++++++++++
 tests/add-missing.tap |    3 ++-
 tests/suffix10.tap    |    2 ++
 5 files changed, 49 insertions(+), 1 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8a009a7..b22e736 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2011-08-14  Stefano Lattarini  <address@hidden>
 
+       maintcheck: look for TAP-based tests without TAP plan
+       * Makefile.am (sc_tests_tap_plan): New maintainer check.
+       (syntax_check_rules): Add it.
+       * tests/suffix10.tap: Declare a TAP plan.
+       * tests/add-missing.tap: Likewise.
+
+2011-08-14  Stefano Lattarini  <address@hidden>
+
        testsuite: avoid confusing SKIP messages for errored tests
        * tests/defs [$use_tap] (exit trap): Don't print the test plan
        in case the client script exited with a non-zero status.  This
diff --git a/Makefile.am b/Makefile.am
index eeb3a6a..3b1751a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -198,6 +198,7 @@ sc_tests_automake_fails \
 sc_tests_plain_aclocal \
 sc_tests_plain_perl \
 sc_tests_required_after_defs \
+sc_tests_tap_plan \
 sc_tests_overriding_macros_on_cmdline \
 sc_tests_plain_sleep \
 sc_tests_plain_egrep_fgrep \
@@ -537,6 +538,26 @@ sc_tests_required_after_defs:
          fi; \
        done
 
+## TAP-based test scripts should not forget to declare a TAP plan.  In
+## case it is not known in advance how many tests will be run, a "lazy"
+## plan can be used; but its use should be deliberate, explicitly declared
+## with a "plan_ later" call, rather than the result of an oversight.
+## This check helps to ensure this is indeed the case.
+sc_tests_tap_plan:
+       @with_plan=`grep -l '^ *plan_ ' $(srcdir)/tests/*.tap`; \
+        with_plan=`echo $$with_plan`; \
+        ok=:; \
+        for t in $(srcdir)/tests/*.tap; do \
+          case " $$with_plan " in \
+            *" $$t "*) ;; \
+            *) ok=false; echo $$t;; \
+          esac; \
+        done; \
+        $$ok || { \
+         echo 'The tests above do not declare a TAP plan.' 1>&2; \
+         exit 1; \
+        }
+
 ## Overriding a Makefile macro on the command line is not portable when
 ## recursive targets are used.  Better use an envvar.  SHELL is an
 ## exception, POSIX says it can't come from the environment.  V, DESTDIR,
diff --git a/Makefile.in b/Makefile.in
index bcebf02..d0611e4 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -327,6 +327,7 @@ sc_tests_automake_fails \
 sc_tests_plain_aclocal \
 sc_tests_plain_perl \
 sc_tests_required_after_defs \
+sc_tests_tap_plan \
 sc_tests_overriding_macros_on_cmdline \
 sc_tests_plain_sleep \
 sc_tests_plain_egrep_fgrep \
@@ -1272,6 +1273,21 @@ sc_tests_required_after_defs:
          fi; \
        done
 
+sc_tests_tap_plan:
+       @with_plan=`grep -l '^ *plan_ ' $(srcdir)/tests/*.tap`; \
+        with_plan=`echo $$with_plan`; \
+        ok=:; \
+        for t in $(srcdir)/tests/*.tap; do \
+          case " $$with_plan " in \
+            *" $$t "*) ;; \
+            *) ok=false; echo $$t;; \
+          esac; \
+        done; \
+        $$ok || { \
+         echo 'The tests above do not declare a TAP plan.' 1>&2; \
+         exit 1; \
+        }
+
 sc_tests_overriding_macros_on_cmdline:
        @if grep -E '\$$MAKE .*(SHELL=.*=|=.*SHELL=)' $(srcdir)/tests/*.test; 
then \
          echo 'Rewrite "$$MAKE foo=bar SHELL=$$SHELL" as "foo=bar $$MAKE -e 
SHELL=$$SHELL"' 1>&2; \
diff --git a/tests/add-missing.tap b/tests/add-missing.tap
index 491f167..36f7676 100755
--- a/tests/add-missing.tap
+++ b/tests/add-missing.tap
@@ -22,8 +22,9 @@
 am_create_testdir=empty
 . ./defs || Exit 1
 
-build_aux=build-aux
+plan_ "later"
 
+build_aux=build-aux
 ocwd=`pwd` || fatal_ "cannot get current working directory"
 
 # Try to improve readability of displayed diffs.
diff --git a/tests/suffix10.tap b/tests/suffix10.tap
index d71450d..2999524 100755
--- a/tests/suffix10.tap
+++ b/tests/suffix10.tap
@@ -20,6 +20,8 @@
 required='cc libtoolize yacc'
 . ./defs || Exit 1
 
+plan_ 7
+
 cat >>configure.in <<EOF
 AC_PROG_CC
 AC_PROG_YACC
-- 
1.7.2.3




reply via email to

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