summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2020-11-25 15:24:54 -0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2020-11-25 15:24:54 -0800
commit7bd645e21d1ec66ec265d83e7f68e21086cc0a98 (patch)
tree1e9659022f63dc1a381edcb39dba6cf6a2578b47
parentMerge branch 'rs/plug-diff-cache-leak' (diff)
parenttests: fix description of 'test_set_prereq' (diff)
downloadtgif-7bd645e21d1ec66ec265d83e7f68e21086cc0a98.tar.xz
Merge branch 'sg/tests-prereq'
A lazily defined test prerequisite can now be defined in terms of another lazily defined test prerequisite. * sg/tests-prereq: tests: fix description of 'test_set_prereq' tests: make sure nested lazy prereqs work reliably
-rwxr-xr-xt/t0000-basic.sh21
-rw-r--r--t/test-lib-functions.sh8
2 files changed, 25 insertions, 4 deletions
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index 22489c24dc..f4ba2e8c85 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -840,6 +840,27 @@ then
exit 1
fi
+test_lazy_prereq NESTED_INNER '
+ >inner &&
+ rm -f outer
+'
+test_lazy_prereq NESTED_PREREQ '
+ >outer &&
+ test_have_prereq NESTED_INNER &&
+ echo "can create new file in cwd" >file &&
+ test -f outer &&
+ test ! -f inner
+'
+test_expect_success NESTED_PREREQ 'evaluating nested lazy prereqs dont interfere with each other' '
+ nestedworks=yes
+'
+
+if test -z "$GIT_TEST_FAIL_PREREQS_INTERNAL" && test "$nestedworks" != yes
+then
+ say 'bug in test framework: nested lazy prerequisites do not work'
+ exit 1
+fi
+
test_expect_success 'lazy prereqs do not turn off tracing' "
run_sub_test_lib_test lazy-prereq-and-tracing \
'lazy prereqs and -x' -v -x <<-\\EOF &&
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 59bbf75e83..7ba3011b90 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -423,7 +423,7 @@ write_script () {
# - Explicitly using test_have_prereq.
#
# - Implicitly by specifying the prerequisite tag in the calls to
-# test_expect_{success,failure,code}.
+# test_expect_{success,failure} and test_external{,_without_stderr}.
#
# The single parameter is the prerequisite tag (a simple word, in all
# capital letters by convention).
@@ -474,15 +474,15 @@ test_lazy_prereq () {
test_run_lazy_prereq_ () {
script='
-mkdir -p "$TRASH_DIRECTORY/prereq-test-dir" &&
+mkdir -p "$TRASH_DIRECTORY/prereq-test-dir-'"$1"'" &&
(
- cd "$TRASH_DIRECTORY/prereq-test-dir" &&'"$2"'
+ cd "$TRASH_DIRECTORY/prereq-test-dir-'"$1"'" &&'"$2"'
)'
say >&3 "checking prerequisite: $1"
say >&3 "$script"
test_eval_ "$script"
eval_ret=$?
- rm -rf "$TRASH_DIRECTORY/prereq-test-dir"
+ rm -rf "$TRASH_DIRECTORY/prereq-test-dir-$1"
if test "$eval_ret" = 0; then
say >&3 "prerequisite $1 ok"
else