X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;ds=sidebyside;f=test%2Ftest-lib.sh;h=bffac77a870656e82ba98d9e342c41e06fd95276;hb=2621f6cef19acc99745c389f5e324fea55f655d8;hp=d7282ff66efa6cc237cfe56d20567a170694ffab;hpb=716e9a45b9cfc44618edfcc2fbf9b7a066b37f1a;p=notmuch diff --git a/test/test-lib.sh b/test/test-lib.sh index d7282ff6..bffac77a 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -556,8 +556,8 @@ test_declare_external_prereq () { hash $binary 2>/dev/null || eval " test_missing_external_prereq_${binary}_=t $binary () { - echo -n \"\$test_subtest_missing_external_prereqs_\" | grep -e \" $name \" || - test_subtest_missing_external_prereqs_=\"$test_subtest_missing_external_prereqs_ $name\" + echo -n \"\$test_subtest_missing_external_prereqs_ \" | grep -qe \" $name \" || + test_subtest_missing_external_prereqs_=\"\$test_subtest_missing_external_prereqs_ $name\" false }" } @@ -919,6 +919,46 @@ test_emacs () { emacsclient --socket-name="$EMACS_SERVER" --eval "(progn $@)" } +test_python() { + export LD_LIBRARY_PATH=$TEST_DIRECTORY/../lib + export PYTHONPATH=$TEST_DIRECTORY/../bindings/python + + (echo "import sys; _orig_stdout=sys.stdout; sys.stdout=open('OUTPUT', 'w')"; cat) \ + | python - +} + +# Creates a script that counts how much time it is executed and calls +# notmuch. $notmuch_counter_command is set to the path to the +# generated script. Use notmuch_counter_value() function to get the +# current counter value. +notmuch_counter_reset () { + notmuch_counter_command="$TMP_DIRECTORY/notmuch_counter" + if [ ! -x "$notmuch_counter_command" ]; then + notmuch_counter_state_path="$TMP_DIRECTORY/notmuch_counter.state" + cat >"$notmuch_counter_command" < "$notmuch_counter_state_path" + +exec notmuch "\$@" +EOF + chmod +x "$notmuch_counter_command" || return + fi + + echo 0 > "$notmuch_counter_state_path" +} + +# Returns the current notmuch counter value. +notmuch_counter_value () { + if [ -r "$notmuch_counter_state_path" ]; then + read count < "$notmuch_counter_state_path" + else + count=0 + fi + echo $count +} + test_reset_state_ () { test -z "$test_init_done_" && test_init_ @@ -1148,3 +1188,4 @@ test_declare_external_prereq emacs test_declare_external_prereq emacsclient test_declare_external_prereq gdb test_declare_external_prereq gpg +test_declare_external_prereq python