diff options
author | Dmitry Kurochkin <dmitry.kurochkin@gmail.com> | 2011-11-27 22:36:17 +0400 |
---|---|---|
committer | David Bremner <bremner@debian.org> | 2011-11-27 11:32:52 -0800 |
commit | f0fbdad04bd60990ed556232a3acd61cd1c60fcf (patch) | |
tree | 5ef5333ac8436678cd6afd38483b2e047f194c6c /test | |
parent | d095902266a79d5475ee9890b9314d2264439dc1 (diff) |
test: add function to explicitly check for external dependencies
Useful when binary is called indirectly (e.g. from emacs).
Diffstat (limited to 'test')
-rw-r--r-- | test/test-lib.sh | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/test-lib.sh b/test/test-lib.sh index fe80e893..2422e32d 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -555,12 +555,26 @@ test_declare_external_prereq () { hash $binary 2>/dev/null || eval " $binary () { + test_missing_external_prereq_${binary}_=t echo -n \"\$test_subtest_missing_external_prereqs_\" | grep -e \" $name \" || test_subtest_missing_external_prereqs_=\"$test_subtest_missing_external_prereqs_ $name\" false }" } +# Explicitly require external prerequisite. Useful when binary is +# called indirectly (e.g. from emacs). +# Returns success if dependency is available, failure otherwise. +test_require_external_prereq () { + binary="$1" + if [ "$(eval echo -n \$test_missing_external_prereq_${binary}_)" = t ]; then + # dependency is missing, call the replacement function to note it + eval "$binary" + else + true + fi +} + # You are not expected to call test_ok_ and test_failure_ directly, use # the text_expect_* functions instead. |