maint.mk: improve sc_cross_check_PATH_usage_in_tests
authorJim Meyering <meyering@redhat.com>
Sun, 9 May 2010 20:30:09 +0000 (22:30 +0200)
committerJim Meyering <meyering@redhat.com>
Sun, 9 May 2010 20:40:34 +0000 (22:40 +0200)
With my recent change in init.sh from the two-line form:
    -#   : ${srcdir=.}
    -#   . "$srcdir/init.sh"; path_prepend_ .
    +#   . "${srcdir=.}/init.sh"; path_prepend_ .
I noticed that using the one-line form would cause this test
to fail with a false-positive, or to stop working altogether,
depending on whether help-version changed or all the tests did.
* top/maint.mk (_hv_regex): Remove this definition.
(_hv_regex_weak): Use a weak regex to select all init.sh-sourcing files.
(_hv_regex_strong): Use a stronger regex to check for conformance.
(sc_cross_check_PATH_usage_in_tests): Rewrite to use the above.
Give a separate diagnostic for lack of conforming use.

ChangeLog
top/maint.mk

index 9c36c82186fcb2ac00caa7e9f2fc5fcc8ac7653e..63d40c327c3f53eed020aebcd9975de3661db9b4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,6 +9,20 @@
 
 2010-05-09  Jim Meyering  <meyering@redhat.com>
 
+       maint.mk: improve sc_cross_check_PATH_usage_in_tests
+       With my recent change in init.sh from the two-line form:
+           -#   : ${srcdir=.}
+           -#   . "$srcdir/init.sh"; path_prepend_ .
+           +#   . "${srcdir=.}/init.sh"; path_prepend_ .
+       I noticed that using the one-line form would cause this test
+       to fail with a false-positive, or to stop working altogether,
+       depending on whether help-version changed or all the tests did.
+       * top/maint.mk (_hv_regex): Remove this definition.
+       (_hv_regex_weak): Use a weak regex to select all init.sh-sourcing files.
+       (_hv_regex_strong): Use a stronger regex to check for conformance.
+       (sc_cross_check_PATH_usage_in_tests): Rewrite to use the above.
+       Give a separate diagnostic for lack of conforming use.
+
        maint.mk: prohibit definition of symbols defined by gnulib
        * top/maint.mk (sc_prohibit_always-defined_macros): Reject the
        definition of symbols defined by gnulib.
index 8d3d137d8fdbd59cd4ac4844bb6079b5b88c01aa..2e11ac1387f53bd2b527c1ff584d9cfadf28036d 100644 (file)
@@ -979,20 +979,22 @@ sc_copyright_check:
 # sets PATH correctly.  This is an inexpensive way to ensure that
 # the other init.sh-using tests also get it right.
 _hv_file ?= $(srcdir)/tests/help-version
-_hv_regex ?= ^ *\. [^ ]*/init\.sh
+_hv_regex_weak ?= ^ *\. .*/init\.sh"
+_hv_regex_strong ?= ^ *\. "\$${srcdir=\.}/init\.sh"
 sc_cross_check_PATH_usage_in_tests:
        @if test -f $(_hv_file); then                                   \
-         if grep -l 'VERSION mismatch' $(_hv_file) >/dev/null          \
-             && grep -lE '$(_hv_regex)' $(_hv_file) >/dev/null; then   \
-           good=$$(grep -E '$(_hv_regex)' < $(_hv_file));              \
-           grep -LFx "$$good"                                          \
-                 $$(grep -lE '$(_hv_regex)' $$($(VC_LIST_EXCEPT)))     \
-               | grep . &&                                             \
-             { echo "$(ME): the above files use path_prepend_ inconsistently" \
-                 1>&2; exit 1; } || :;                                 \
-         fi;                                                           \
-       else                                                            \
-         echo "$@: skipped: no such file: $(_hv_file)";                \
+         grep -l 'VERSION mismatch' $(_hv_file) >/dev/null             \
+           || { echo "$@: skipped: no such file: $(_hv_file)" 1>&2;    \
+                exit 0; };                                             \
+         grep -lE '$(_hv_regex_strong)' $(_hv_file) >/dev/null         \
+           || { echo "$@: $(_hv_file) lacks conforming use of init.sh" 1>&2; \
+                exit 1; };                                             \
+         good=$$(grep -E '$(_hv_regex_strong)' $(_hv_file));           \
+         grep -LFx "$$good"                                            \
+               $$(grep -lE '$(_hv_regex_weak)' $$($(VC_LIST_EXCEPT)))  \
+             | grep . &&                                               \
+           { echo "$(ME): the above files use path_prepend_ inconsistently" \
+               1>&2; exit 1; } || :;                                   \
        fi
 
 # #if HAVE_... will evaluate to false for any non numeric string.