maintainer-check coverage for variables before rules.
authorRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sun, 3 Oct 2010 09:45:31 +0000 (11:45 +0200)
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sun, 3 Oct 2010 09:45:31 +0000 (11:45 +0200)
* Makefile.am (sc_ensure_testsuite_has_run): Suggest keeping
around the test directories.
(sc_tests_makefile_variable_order): New rule with a heuristic to
catch ordering violations.

Signed-off-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
ChangeLog
Makefile.am
Makefile.in

index b608c94..5a15698 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2010-10-03  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
+       maintainer-check coverage for variables before rules.
+       * Makefile.am (sc_ensure_testsuite_has_run): Suggest keeping
+       around the test directories.
+       (sc_tests_makefile_variable_order): New rule with a heuristic to
+       catch ordering violations.
+
        Document and fix expansion of variables before rules.
        * doc/automake.texi (General Operation): Document that variables
        are expanded before rules.
index 8eb1bde..a5df109 100644 (file)
@@ -195,6 +195,7 @@ sc_tests_plain_sleep \
 sc_tests_plain_egrep_fgrep \
 sc_tests_PATH_SEPARATOR \
 sc_tests_logs_duplicate_prefixes \
+sc_tests_makefile_variable_order \
 sc_mkdir_p \
 sc_perl_at_substs \
 sc_unquoted_DESTDIR \
@@ -467,9 +468,10 @@ sc_tests_plain_egrep_fgrep:
 ## Rule to ensure that the testsuite has been run before.  We don't depend on `check'
 ## here, because that would be very wasteful in the common case.  We could run
 ## `make check RECHECK_LOGS=' and avoid toplevel races with AM_RECURSIVE_TARGETS.
+## Suggest keeping test directories around for greppability of the Makefile.in files.
 sc_ensure_testsuite_has_run:
        @if test ! -f tests/test-suite.log; then \
-         echo "Run \`make check' before \`maintainer-check'" >&2; \
+         echo "Run \`env keep_testdirs=yes make check' before \`maintainer-check'" >&2; \
          exit 1; \
        fi
 .PHONY: sc_ensure_testsuite_has_run
@@ -482,6 +484,24 @@ sc_tests_logs_duplicate_prefixes: sc_ensure_testsuite_has_run
          exit 1; \
        fi
 
+## Ensure variables are listed before rules in Makefile.in files we generate.
+sc_tests_makefile_variable_order: sc_ensure_testsuite_has_run
+       @for file in `find tests -name Makefile.in -print`; do \
+         latevars=`sed -n \
+           -e :x -e 's/#.*//' \
+           -e '/\\\\$$/{' -e N -e 'b x' -e '}' \
+## Literal TAB.
+           -e '1,/^    /d' \
+## Allow @ so we match conditionals.
+           -e '/^ *[a-zA-Z_@]\{1,\} *=/p' $$file`; \
+         if test -n "$$latevars"; then \
+           echo 'Ensure variables are expanded before rules' >&2; \
+           echo "Variables are expanded too late in $$file:" >&2; \
+           echo "$$latevars" | sed 's/^/  /' >&2; \
+           exit 1; \
+         fi; \
+       done
+
 ## Using `:' as a PATH separator is not portable.
 sc_tests_PATH_SEPARATOR:
        @if grep -E '\bPATH=.*:.*' $(srcdir)/tests/*.test ; then \
index f468541..232fbf7 100644 (file)
@@ -316,6 +316,7 @@ sc_tests_plain_sleep \
 sc_tests_plain_egrep_fgrep \
 sc_tests_PATH_SEPARATOR \
 sc_tests_logs_duplicate_prefixes \
+sc_tests_makefile_variable_order \
 sc_mkdir_p \
 sc_perl_at_substs \
 sc_unquoted_DESTDIR \
@@ -1188,7 +1189,7 @@ sc_tests_plain_egrep_fgrep:
 
 sc_ensure_testsuite_has_run:
        @if test ! -f tests/test-suite.log; then \
-         echo "Run \`make check' before \`maintainer-check'" >&2; \
+         echo "Run \`env keep_testdirs=yes make check' before \`maintainer-check'" >&2; \
          exit 1; \
        fi
 .PHONY: sc_ensure_testsuite_has_run
@@ -1199,6 +1200,21 @@ sc_tests_logs_duplicate_prefixes: sc_ensure_testsuite_has_run
          exit 1; \
        fi
 
+sc_tests_makefile_variable_order: sc_ensure_testsuite_has_run
+       @for file in `find tests -name Makefile.in -print`; do \
+         latevars=`sed -n \
+           -e :x -e 's/#.*//' \
+           -e '/\\\\$$/{' -e N -e 'b x' -e '}' \
+           -e '1,/^    /d' \
+           -e '/^ *[a-zA-Z_@]\{1,\} *=/p' $$file`; \
+         if test -n "$$latevars"; then \
+           echo 'Ensure variables are expanded before rules' >&2; \
+           echo "Variables are expanded too late in $$file:" >&2; \
+           echo "$$latevars" | sed 's/^/  /' >&2; \
+           exit 1; \
+         fi; \
+       done
+
 sc_tests_PATH_SEPARATOR:
        @if grep -E '\bPATH=.*:.*' $(srcdir)/tests/*.test ; then \
          echo "Use \`$$PATH_SEPARATOR', not \`:', in PATH definitions above." 1>&2; \