[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 28/32] tests: protect test libs against multiple inclusion
From: |
Stefano Lattarini |
Subject: |
[PATCH 28/32] tests: protect test libs against multiple inclusion |
Date: |
Thu, 26 Jul 2012 14:04:54 +0200 |
* 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 <address@hidden>
---
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 172347f..d255288 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 aaa8df5..8a0e117 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 60ffd98..9a530b1 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
--
1.7.12.rc0
- [PATCH 19/32] test init: refactor: move displaying of debugging info later, (continued)
- [PATCH 19/32] test init: refactor: move displaying of debugging info later, Stefano Lattarini, 2012/07/26
- [PATCH 16/32] configure: testsuite shell set exit traps in shell functions, Stefano Lattarini, 2012/07/26
- [PATCH 21/32] test setup: merge definitions of function for simple tests, Stefano Lattarini, 2012/07/26
- [PATCH 23/32] tests: split test libs into "generic" and "automake-specific", Stefano Lattarini, 2012/07/26
- [PATCH 27/32] configure: testsuite shell can return early from "dot-sourced" files, Stefano Lattarini, 2012/07/26
- [PATCH 25/32] tests: source test defs in the generic test lib, Stefano Lattarini, 2012/07/26
- [PATCH 22/32] test setup: move actual calling of testsuite setup in ./defs, Stefano Lattarini, 2012/07/26
- [PATCH 26/32] tests: move sanitization and "Bournification" in the generic test lib, Stefano Lattarini, 2012/07/26
- [PATCH 24/32] test defs: no need to re-add $srcdir/t/ax to $PATH, Stefano Lattarini, 2012/07/26
- [PATCH 20/32] test init: refactor: new function 'am_test_setup', Stefano Lattarini, 2012/07/26
- [PATCH 28/32] tests: protect test libs against multiple inclusion,
Stefano Lattarini <=
- [PATCH 29/32] tests: "am_using_tap=yes" -> "am_test_protocol=tap", Stefano Lattarini, 2012/07/26
- [PATCH 31/32] runtest: sanitize test environment, Stefano Lattarini, 2012/07/26
- [PATCH 30/32] tests: remove an obsolescent self test, Stefano Lattarini, 2012/07/26
- [PATCH 32/32] tests: never source test-defs.sh directly, source test-lib.sh instead, Stefano Lattarini, 2012/07/26
- [PATCH 33/32] maintcheck: fixup list of files in $(xdefs), Stefano Lattarini, 2012/07/26
- Re: [PATCH 00/32] {maint} Several testsuite refactorings, Stefano Lattarini, 2012/07/26