From f6b9a22e7e7de330961cecdb55dbfcf15bb7e3c9 Mon Sep 17 00:00:00 2001 From: Stefano Lattarini Date: Fri, 24 May 2013 12:46:17 +0200 Subject: [PATCH] tests: ensure $required is not set too late 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 --- syntax-checks.mk | 10 ---------- t/ax/test-init.sh | 4 ++++ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/syntax-checks.mk b/syntax-checks.mk index 99e88f6..82fd499 100644 --- a/syntax-checks.mk +++ b/syntax-checks.mk @@ -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 diff --git a/t/ax/test-init.sh b/t/ax/test-init.sh index 42db050..daf0bba 100644 --- a/t/ax/test-init.sh +++ b/t/ax/test-init.sh @@ -17,6 +17,10 @@ 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 -- 2.7.4