Skip to content

Commit 5024ade

Browse files
FStelzergitster
authored andcommitted
test-lib: introduce required prereq for test runs
In certain environments or for specific test scenarios we might expect a specific prerequisite check to succeed. Therefore we would like to abort running our tests if this is not the case. To remedy this we add the environment variable GIT_TEST_REQUIRE_PREREQ which can be set to a space separated list of prereqs. If one of these prereq tests fail then the whole test run will abort. Signed-off-by: Fabian Stelzer <fs@gigacodes.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 49da404 commit 5024ade

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

t/README

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,12 @@ explicitly providing repositories when accessing submodule objects is
466466
complete or needs to be abandoned for whatever reason (in which case the
467467
migrated codepaths still retain their performance benefits).
468468

469+
GIT_TEST_REQUIRE_PREREQ=<list> allows specifying a space speparated list of
470+
prereqs that are required to succeed. If a prereq in this list is triggered by
471+
a test and then fails then the whole test run will abort. This can help to make
472+
sure the expected tests are executed and not silently skipped when their
473+
dependency breaks or is simply not present in a new environment.
474+
469475
Naming Tests
470476
------------
471477

t/test-lib-functions.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,17 @@ test_have_prereq () {
680680
# Keep a list of missing prerequisites; restore
681681
# the negative marker if necessary.
682682
prerequisite=${negative_prereq:+!}$prerequisite
683+
684+
# Abort if this prereq was marked as required
685+
if test -n "$GIT_TEST_REQUIRE_PREREQ"
686+
then
687+
case " $GIT_TEST_REQUIRE_PREREQ " in
688+
*" $prerequisite "*)
689+
BAIL_OUT "required prereq $prerequisite failed"
690+
;;
691+
esac
692+
fi
693+
683694
if test -z "$missing_prereq"
684695
then
685696
missing_prereq=$prerequisite

0 commit comments

Comments
 (0)