Skip to content

Commit 7bd645e

Browse files
committed
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
2 parents ca06552 + 7f9c59d commit 7bd645e

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

t/t0000-basic.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,27 @@ then
840840
exit 1
841841
fi
842842

843+
test_lazy_prereq NESTED_INNER '
844+
>inner &&
845+
rm -f outer
846+
'
847+
test_lazy_prereq NESTED_PREREQ '
848+
>outer &&
849+
test_have_prereq NESTED_INNER &&
850+
echo "can create new file in cwd" >file &&
851+
test -f outer &&
852+
test ! -f inner
853+
'
854+
test_expect_success NESTED_PREREQ 'evaluating nested lazy prereqs dont interfere with each other' '
855+
nestedworks=yes
856+
'
857+
858+
if test -z "$GIT_TEST_FAIL_PREREQS_INTERNAL" && test "$nestedworks" != yes
859+
then
860+
say 'bug in test framework: nested lazy prerequisites do not work'
861+
exit 1
862+
fi
863+
843864
test_expect_success 'lazy prereqs do not turn off tracing' "
844865
run_sub_test_lib_test lazy-prereq-and-tracing \
845866
'lazy prereqs and -x' -v -x <<-\\EOF &&

t/test-lib-functions.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ write_script () {
423423
# - Explicitly using test_have_prereq.
424424
#
425425
# - Implicitly by specifying the prerequisite tag in the calls to
426-
# test_expect_{success,failure,code}.
426+
# test_expect_{success,failure} and test_external{,_without_stderr}.
427427
#
428428
# The single parameter is the prerequisite tag (a simple word, in all
429429
# capital letters by convention).
@@ -474,15 +474,15 @@ test_lazy_prereq () {
474474

475475
test_run_lazy_prereq_ () {
476476
script='
477-
mkdir -p "$TRASH_DIRECTORY/prereq-test-dir" &&
477+
mkdir -p "$TRASH_DIRECTORY/prereq-test-dir-'"$1"'" &&
478478
(
479-
cd "$TRASH_DIRECTORY/prereq-test-dir" &&'"$2"'
479+
cd "$TRASH_DIRECTORY/prereq-test-dir-'"$1"'" &&'"$2"'
480480
)'
481481
say >&3 "checking prerequisite: $1"
482482
say >&3 "$script"
483483
test_eval_ "$script"
484484
eval_ret=$?
485-
rm -rf "$TRASH_DIRECTORY/prereq-test-dir"
485+
rm -rf "$TRASH_DIRECTORY/prereq-test-dir-$1"
486486
if test "$eval_ret" = 0; then
487487
say >&3 "prerequisite $1 ok"
488488
else

0 commit comments

Comments
 (0)