While test_expect_success could be used to define these prereqs, this is probably not a good idea: if a prereq is not available, using test_expect_success would result in a test being reported as FAILED at the end of the test suite (and its dependencies as skipped).
(Thanks to Pieter Praet for suggesting the use of "hash" instead of "which".) --- test/test-lib.sh | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-) diff --git a/test/test-lib.sh b/test/test-lib.sh index 1ea7fa9..382934f 100755 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -543,6 +543,19 @@ test_have_prereq () { esac } +test_set_bin_prereq () { + bin=$1 + name=$2 + prereq=$3 + if hash $bin &>/dev/null + then + test_set_prereq $prereq + else + say_color info "%-6s" "INFO" + echo " Missing test prerequisite: $name" + fi +} + # You are not expected to call test_ok_ and test_failure_ directly, use # the text_expect_* functions instead. -- 1.7.7.3