tests: ensure $required is not set too late
authorStefano Lattarini <stefano.lattarini@gmail.com>
Fri, 24 May 2013 10:46:17 +0000 (12:46 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Fri, 24 May 2013 11:15:36 +0000 (13:15 +0200)
And do so in a safer way, with a runtime check rather than a brittle
static maintainer check.

* t/ax/test-init.sh: Set the 'required' variable to readonly.
* syntax-checks.mk (sc_tests_required_after_defs): Remove.
(syntax_check_rules): No longer list it.

Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
syntax-checks.mk
t/ax/test-init.sh

index 99e88f6..82fd499 100644 (file)
@@ -65,7 +65,6 @@ sc_tests_command_subst \
 sc_tests_no_run_make_redirect \
 sc_tests_exit_not_Exit \
 sc_tests_automake_fails \
-sc_tests_required_after_defs \
 sc_tests_overriding_macros_on_cmdline \
 sc_tests_no_make_e \
 sc_tests_plain_sleep \
@@ -357,15 +356,6 @@ sc_tests_automake_fails:
          exit 1; \
        fi
 
-## Setting 'required' after sourcing 'test-init.sh' is a bug.
-sc_tests_required_after_defs:
-       @for file in $(xtests); do \
-         if out=`sed -n '/test-init\.sh/,$${/required=/p;}' $$file`; test -n "$$out"; then \
-           echo 'Do not set "required" after sourcing "test-init.sh" in '"$$file: $$out" 1>&2; \
-           exit 1; \
-         fi; \
-       done
-
 # "make -e" is brittle and unsafe, since it let *all* the environment
 # win over the macro definitions in the Makefiles.  Since we offer
 # AM_MAKEFLAGS to allow the user to portably override macro definitions
index 42db050..daf0bba 100644 (file)
 
 set -e
 
+# The variable '$required' should no longer be modified after this
+# file gets sources.
+required=${required-}; readonly required
+
 # Source the actual code for test initialization and setup.
 . test-lib.sh
 . am-test-lib.sh