Skip to content

Commit ab362fc

Browse files
committed
t: document test_lazy_prereq
The t/README file talked about test_set_prereq but lacked explanation on test_lazy_prereq, which is a more modern way to define prerequisites. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 87a0bdb commit ab362fc

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

t/README

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ Skipping tests
818818
--------------
819819

820820
If you need to skip tests you should do so by using the three-arg form
821-
of the test_* functions (see the "Test harness library" section
821+
of the test_expect_* functions (see the "Test harness library" section
822822
below), e.g.:
823823

824824
test_expect_success PERL 'I need Perl' '
@@ -965,6 +965,27 @@ see test-lib-functions.sh for the full list and their options.
965965
test_done
966966
fi
967967

968+
- test_lazy_prereq <prereq> <script>
969+
970+
Declare the way to determine if a test prerequisite <prereq> is
971+
satisified or not, but delay the actual determination until the
972+
prerequisite is actually used by "test_have_prereq" or the
973+
three-arg form of the test_expect_* functions. For example, this
974+
is how the SYMLINKS prerequisite is declared to see if the platform
975+
supports symbolic links:
976+
977+
test_lazy_prereq SYMLINKS '
978+
ln -s x y && test -h y
979+
'
980+
981+
The script is lazily invoked when SYMLINKS prerequisite is first
982+
queried by either "test_have_prereq SYMLINKS" or "test_expect_*
983+
SYMLINKS ...". The script is run in a temporary directory inside
984+
a subshell, so you do not have to worry about removing temporary
985+
files you create there. When the script exits with status 0, the
986+
prerequisite is set. Exiting with non-zero status makes the
987+
prerequisite unsatisified.
988+
968989
- test_expect_code <exit-code> <command>
969990

970991
Run a command and ensure that it exits with the given exit code.

0 commit comments

Comments
 (0)