X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=test%2Ftest-lib-common.sh;h=18fa29c0dd86d3b7eb8ab5c3b69bd7f9a35cf89a;hb=fb4a0967cab7df737d5d53199a48a0e79c429b61;hp=2f7950ac75b7b6c61777560bb933d847b9a7e3f7;hpb=1e4e8e3bf564ea190b42e9347b22c62fa6b78396;p=notmuch diff --git a/test/test-lib-common.sh b/test/test-lib-common.sh index 2f7950ac..18fa29c0 100644 --- a/test/test-lib-common.sh +++ b/test/test-lib-common.sh @@ -29,6 +29,20 @@ if [[ -z "$NOTMUCH_SRCDIR" ]] || [[ -z "$NOTMUCH_BUILDDIR" ]]; then exit 1 fi +# 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 () { + local binary + binary="$1" + if [[ ${test_missing_external_prereq_["${binary}"]} == t ]]; then + # dependency is missing, call the replacement function to note it + eval "$binary" + else + true + fi +} + backup_database () { test_name=$(basename $0 .sh) rm -rf $TMP_DIRECTORY/notmuch-dir-backup."$test_name" @@ -105,8 +119,7 @@ fi gen_msg_cnt=0 gen_msg_filename="" gen_msg_id="" -generate_message () -{ +generate_message () { # This is our (bash-specific) magic for doing named parameters local -A template="($@)" local additional_headers @@ -225,8 +238,7 @@ EOF # # All of the arguments and return values supported by generate_message # are also supported here, so see that function for details. -add_message () -{ +add_message () { generate_message "$@" && notmuch new > /dev/null }