From d8b3c5e4b81986b875f56502006288f43aee5159 Mon Sep 17 00:00:00 2001 From: Stefano Lattarini Date: Thu, 26 Jul 2012 12:21:40 +0200 Subject: [PATCH] tests: protect test libs against multiple inclusion * t/ax/test-lib.sh, t/ax/am-test-lib.sh: Return early if already sourced. Use the witness variables '$test_lib_sourced' and '$am_test_lib_sourced', respectively, for this purpose. * runtest.in, Makefile.am (AM_TESTS_ENVIRONMENT): Unset 'test_lib_sourced' and 'am_test_lib_sourced', to avoid interferences from the environment. Signed-off-by: Stefano Lattarini --- Makefile.am | 2 ++ t/ax/am-test-lib.sh | 4 ++++ t/ax/test-lib.sh | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/Makefile.am b/Makefile.am index ce502b4ec..e55e43de6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -342,6 +342,8 @@ AM_TESTS_ENVIRONMENT = \ am_test_prefer_config_shell \ am_original_AUTOMAKE \ am_original_ACLOCAL \ + am_test_lib_sourced \ + test_lib_sourced \ ; do \ eval test x"\$${$$v}" = x || unset $$v; \ done; diff --git a/t/ax/am-test-lib.sh b/t/ax/am-test-lib.sh index aaa8df540..8a0e11726 100644 --- a/t/ax/am-test-lib.sh +++ b/t/ax/am-test-lib.sh @@ -19,6 +19,10 @@ ### IMPORTANT NOTE: keep this file 'set -e' clean. ### ######################################################## +# Do not source several times. +test ${am_test_lib_sourced-no} = yes && return 0 +am_test_lib_sourced=yes + # A literal escape character. Used by test checking colored output. esc='' diff --git a/t/ax/test-lib.sh b/t/ax/test-lib.sh index 60ffd9871..9a530b16e 100644 --- a/t/ax/test-lib.sh +++ b/t/ax/test-lib.sh @@ -19,6 +19,10 @@ ### IMPORTANT NOTE: keep this file 'set -e' clean. ### ######################################################## +# Do not source several times. +test ${test_lib_sourced-no} = yes && return 0 +test_lib_sourced=yes + # CDPATH is evil if used in non-interactive scripts (and even more # evil if exported in the environment). CDPATH=; unset CDPATH -- 2.47.2