tests: maint.mk: make sc_require_test_exit_idiom more generic
authorJim Meyering <meyering@redhat.com>
Fri, 19 Jun 2009 12:25:37 +0000 (14:25 +0200)
committerJim Meyering <meyering@redhat.com>
Fri, 19 Jun 2009 22:05:04 +0000 (00:05 +0200)
* top/maint.mk (Exit_witness_file): New overridable variable.
(sc_require_test_exit_idiom): Don't hard-code tests/test-lib.sh.
Relax test for /^Exit \$fail$$/ to just /^Exit ./.

ChangeLog
top/maint.mk

index 6553c47..91a213f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-06-20  Jim Meyering  <meyering@redhat.com>
+
+       tests: make sc_require_test_exit_idiom more generic
+       * top/maint.mk (Exit_witness_file): New overridable variable.
+       (sc_require_test_exit_idiom): Don't hard-code tests/test-lib.sh.
+       Relax test for /^Exit \$fail$$/ to just /^Exit ./.
+
 2009-06-19  Jim Meyering  <meyering@redhat.com>
 
        hash: reverse order of src/dst parameters in an internal interface
index ed9c1aa..ef828d1 100644 (file)
@@ -363,16 +363,19 @@ sc_program_name:
 # Require that the final line of each test-lib.sh-using test be this one:
 # Exit $fail
 # Note: this test requires GNU grep's --label= option.
+Exit_witness_file ?= tests/test-lib.sh
+Exit_base := $(notdir $(Exit_witness_file))
 sc_require_test_exit_idiom:
-       @if test -f $(srcdir)/tests/test-lib.sh; then                   \
+       @if test -f $(srcdir)/$(Exit_witness_file); then                \
          die=0;                                                        \
-         for i in $$(grep -l -F /../test-lib.sh $$($(VC_LIST) tests)); do \
-           tail -n1 $$i | grep '^Exit \$$fail$$' > /dev/null           \
+         for i in $$(grep -l -F 'srcdir/$(Exit_base)'                  \
+               $$($(VC_LIST) tests)); do                               \
+           tail -n1 $$i | grep '^Exit .' > /dev/null                   \
              && : || { die=1; echo $$i; }                              \
          done;                                                         \
          test $$die = 1 &&                                             \
            { echo 1>&2 '$(ME): the final line in each of the above is not:'; \
-             echo 1>&2 'Exit $$fail';                                  \
+             echo 1>&2 'Exit something';                               \
              exit 1; } || :;                                           \
        fi