Re: [PATCH] emacs: notmuch-search: avoid wiping out buffer-local variables
Sean Whitton writes: > --- > emacs/notmuch.el | 6 +- > 1 file changed, 5 insertions(+), 1 deletion(-) applied to master d ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: [PATCH] emacs: notmuch-search: avoid wiping out buffer-local variables
On Wednesday, 2020-07-22 at 08:11:32 -07, Sean Whitton wrote: > Reviewed-by: David Edmondson > --- > emacs/notmuch.el | 6 +- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/emacs/notmuch.el b/emacs/notmuch.el > index dd18f2e1..c97997fe 100644 > --- a/emacs/notmuch.el > +++ b/emacs/notmuch.el > @@ -987,7 +987,11 @@ the configured default sort order." > (if no-display > (set-buffer buffer) >(switch-to-buffer buffer)) > -(notmuch-search-mode) > +;; avoid wiping out third party buffer-local variables in the case > +;; where we're just refreshing or changing the sort order of an > +;; existing search results buffer > +(unless (eq major-mode 'notmuch-search-mode) > + (notmuch-search-mode)) > ;; Don't track undo information for this buffer > (set 'buffer-undo-list t) > (set 'notmuch-search-query-string query) > -- > 2.27.0 > ___ > notmuch mailing list -- notmuch@notmuchmail.org > To unsubscribe send an email to notmuch-le...@notmuchmail.org dme. -- Hello? Is anybody home? Well, you don't know me, but I know you. ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
[PATCH] emacs: notmuch-search: avoid wiping out buffer-local variables
--- emacs/notmuch.el | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/emacs/notmuch.el b/emacs/notmuch.el index dd18f2e1..c97997fe 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -987,7 +987,11 @@ the configured default sort order." (if no-display (set-buffer buffer) (switch-to-buffer buffer)) -(notmuch-search-mode) +;; avoid wiping out third party buffer-local variables in the case +;; where we're just refreshing or changing the sort order of an +;; existing search results buffer +(unless (eq major-mode 'notmuch-search-mode) + (notmuch-search-mode)) ;; Don't track undo information for this buffer (set 'buffer-undo-list t) (set 'notmuch-search-query-string query) -- 2.27.0 ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: [PATCH 4/4] lib/n_d_get_version: catch exceptions and clarify the API
David Bremner writes: > notmuch_database_get_version previously returned 0 on some errors, but > did not document this. Luckily 0 is not a valid database version. > +static void > +_log_xapian_exception (const char *where, notmuch_database_t *notmuch, > const Xapian::Error error) { > +_notmuch_database_log (notmuch, > +"A Xapian exception occurred %s accessing %s : %s\n", > +where, > +error.get_msg ().c_str ()); > +notmuch->exception_reported = true; > +} > + I realized this has the same extra '%s' as fixed in id:20200722120905.472562-2-da...@tethera.net for message.cc. So this patch will need to be updated, and possibly some of the tests as well. ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
[PATCH 2/2] lib: fix exception messages for n_m_message_*
The original generic handler had an extra '%s' in the format string. Update tests that failed to catch this because the template to print status strings checked 'stat', which was not set. --- lib/message.cc | 2 +- test/T560-lib-error.sh | 67 +++--- 2 files changed, 44 insertions(+), 25 deletions(-) diff --git a/lib/message.cc b/lib/message.cc index 87448101..64798413 100644 --- a/lib/message.cc +++ b/lib/message.cc @@ -96,7 +96,7 @@ static void _log_xapian_exception (const char *where, notmuch_message_t *message, const Xapian::Error error) { notmuch_database_t *notmuch = notmuch_message_get_database (message); _notmuch_database_log (notmuch, - "A Xapian exception occurred %s retrieving %s : %s\n", + "A Xapian exception occurred at %s: %s\n", where, error.get_msg ().c_str ()); notmuch->exception_reported = true; diff --git a/test/T560-lib-error.sh b/test/T560-lib-error.sh index fda1f170..8a608341 100755 --- a/test/T560-lib-error.sh +++ b/test/T560-lib-error.sh @@ -345,6 +345,7 @@ cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} const char *id2; id2=notmuch_message_get_message_id (message); printf("%d\n%d\n", message != NULL, id2==NULL); +stat = NOTMUCH_STATUS_XAPIAN_EXCEPTION; } EOF cat < EXPECTED @@ -352,6 +353,7 @@ cat < EXPECTED 1 1 == stderr == +A Xapian exception occurred at lib/message.cc:XXX: Database has been closed EOF test_expect_equal_file EXPECTED OUTPUT @@ -361,6 +363,7 @@ cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} const char *id2; id2=notmuch_message_get_thread_id (message); printf("%d\n%d\n", message != NULL, id2==NULL); +stat = NOTMUCH_STATUS_XAPIAN_EXCEPTION; } EOF cat < EXPECTED @@ -368,6 +371,7 @@ cat < EXPECTED 1 1 == stderr == +A Xapian exception occurred at lib/message.cc:XXX: Database has been closed EOF test_expect_equal_file EXPECTED OUTPUT @@ -377,6 +381,7 @@ cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} const char *from; from=notmuch_message_get_header (message, "from"); printf("%s\n%d\n", id, from == NULL); +stat = NOTMUCH_STATUS_XAPIAN_EXCEPTION; } EOF cat < EXPECTED @@ -384,6 +389,7 @@ cat < EXPECTED 1258471718-6781-1-git-send-email-dotted...@dottedmag.net 1 == stderr == +A Xapian exception occurred at lib/message.cc:XXX: Database has been closed EOF test_expect_equal_file EXPECTED OUTPUT @@ -395,6 +401,7 @@ cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} notmuch_messages_t *replies; replies = notmuch_message_get_replies (message); printf("%d\n%d\n", message != NULL, replies==NULL); +stat = NOTMUCH_STATUS_XAPIAN_EXCEPTION; } EOF cat < EXPECTED @@ -411,6 +418,7 @@ cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} const char *filename; filename = notmuch_message_get_filename (message); printf("%d\n%d\n", message != NULL, filename == NULL); +stat = NOTMUCH_STATUS_XAPIAN_EXCEPTION; } EOF cat < EXPECTED @@ -418,6 +426,7 @@ cat < EXPECTED 1 1 == stderr == +A Xapian exception occurred at lib/message.cc:XXX: Database has been closed EOF test_expect_equal_file EXPECTED OUTPUT @@ -427,6 +436,7 @@ cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} notmuch_filenames_t *filenames; filenames = notmuch_message_get_filenames (message); printf("%d\n%d\n", message != NULL, filenames == NULL); +stat = NOTMUCH_STATUS_XAPIAN_EXCEPTION; } EOF cat < EXPECTED @@ -434,6 +444,7 @@ cat < EXPECTED 1 1 == stderr == +A Xapian exception occurred at lib/message.cc:XXX: Database has been closed EOF test_expect_equal_file EXPECTED OUTPUT @@ -443,6 +454,7 @@ cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} notmuch_bool_t result; result = notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_GHOST); printf("%d\n%d\n", message != NULL, result == FALSE); +stat = NOTMUCH_STATUS_XAPIAN_EXCEPTION; } EOF cat < EXPECTED @@ -450,6 +462,7 @@ cat < EXPECTED 1 1 == stderr == +A Xapian exception occurred at lib/message.cc:XXX: Database has been closed EOF test_expect_equal_file EXPECTED OUTPUT @@ -459,6 +472,7 @@ cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} time_t result; result = notmuch_message_get_date (message); printf("%d\n%d\n", message != NULL, result == 0); +stat = NOTMUCH_STATUS_XAPIAN_EXCEPTION; } EOF cat < EXPECTED @@ -466,6 +480,7 @@ cat < EXPECTED 1 1 == stderr == +A Xapian exception occurred at lib/message.cc:XXX: Database has been closed EOF test_expect_equal_file EXPECTED OUTPUT @@ -475,6 +490,7 @@ cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} notmuch_tags_t *result; result = notmuch_message_get_tags (message);
[PATCH 1/2] test: sanitize line numbers in exception reports
Prevent test suite churn when reported line numbers change. --- test/test-lib.sh | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/test-lib.sh b/test/test-lib.sh index 7424881e..8c331b88 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -619,6 +619,11 @@ print(msg.as_string(False)) ' "$@" } +notmuch_exception_sanitize () +{ +perl -pe 's/(A Xapian exception occurred at .*[.]cc?):([0-9]*)/\1:XXX/' +} + notmuch_search_sanitize () { perl -pe 's/("?thread"?: ?)("?)("?)/\1\2XXX\3/' @@ -1093,7 +1098,7 @@ test_C () { echo "== stdout ==" > OUTPUT.stdout echo "== stderr ==" > OUTPUT.stderr ./${exec_file} "$@" 1>>OUTPUT.stdout 2>>OUTPUT.stderr -notmuch_dir_sanitize OUTPUT.stdout OUTPUT.stderr > OUTPUT +notmuch_dir_sanitize OUTPUT.stdout OUTPUT.stderr | notmuch_exception_sanitize > OUTPUT } make_shim () { -- 2.27.0 ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
[PATCH 02/10] test: add regression test for n_q_{create,_get_query_string}
Start a new file of tests, to keep to the (emerging) scheme of one notmuch_foo group per file --- test/T564-lib-query.sh | 61 ++ 1 file changed, 61 insertions(+) create mode 100755 test/T564-lib-query.sh diff --git a/test/T564-lib-query.sh b/test/T564-lib-query.sh new file mode 100755 index ..103870a6 --- /dev/null +++ b/test/T564-lib-query.sh @@ -0,0 +1,61 @@ +#!/usr/bin/env bash +test_description="notmuch_database_* API" + +. $(dirname "$0")/test-lib.sh || exit 1 + +add_email_corpus + +test_begin_subtest "building database" +test_expect_success "NOTMUCH_NEW" + +cat < c_head +#include +#include +#include +#include +int main (int argc, char** argv) +{ + notmuch_database_t *db; + notmuch_status_t stat; + char *msg = NULL; + + stat = notmuch_database_open_verbose (argv[1], NOTMUCH_DATABASE_MODE_READ_WRITE, , ); + if (stat != NOTMUCH_STATUS_SUCCESS) { + fprintf (stderr, "error opening database: %d %s\n", stat, msg ? msg : ""); + exit (1); + } +EOF + +cat <<'EOF' > c_tail + if (stat) { + const char *stat_str = notmuch_database_status_string (db); + if (stat_str) + fputs (stat_str, stderr); +} + +} +EOF + +test_begin_subtest "roundtrip query string with closed db" +cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} +{ +notmuch_query_t *query; +const char *str = "id:1258471718-6781-1-git-send-email-dotted...@dottedmag.net"; +const char *ret; + +EXPECT0(notmuch_database_close (db)); +query = notmuch_query_create (db, str); +ret = notmuch_query_get_query_string (query); + +printf("%s\n%s\n", str, ret); +} +EOF +cat < EXPECTED +== stdout == +id:1258471718-6781-1-git-send-email-dotted...@dottedmag.net +id:1258471718-6781-1-git-send-email-dotted...@dottedmag.net +== stderr == +EOF +test_expect_equal_file EXPECTED OUTPUT + +test_done -- 2.27.0 ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
[PATCH 03/10] test: regression test for notmuch_query_get_database
Current functionality is too trivial to really justify a test, but it's simpler just to test the complete API. --- test/T564-lib-query.sh | 23 ++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/test/T564-lib-query.sh b/test/T564-lib-query.sh index 103870a6..ac08344f 100755 --- a/test/T564-lib-query.sh +++ b/test/T564-lib-query.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -test_description="notmuch_database_* API" +test_description="notmuch_query_* API" . $(dirname "$0")/test-lib.sh || exit 1 @@ -58,4 +58,25 @@ id:1258471718-6781-1-git-send-email-dotted...@dottedmag.net EOF test_expect_equal_file EXPECTED OUTPUT +test_begin_subtest "retrieve closed db from query" +cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} +{ +notmuch_query_t *query; +const char *str = "id:1258471718-6781-1-git-send-email-dotted...@dottedmag.net"; +notmuch_database_t *db2; + +query = notmuch_query_create (db, str); +EXPECT0(notmuch_database_close (db)); +db2 = notmuch_query_get_database (query); + +printf("%d\n", db == db2); +} +EOF +cat < EXPECTED +== stdout == +1 +== stderr == +EOF +test_expect_equal_file EXPECTED OUTPUT + test_done -- 2.27.0 ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
[PATCH 05/10] test: regression test for n_q_{set, get}_sort
We just want to make sure accessing the query owned by a closed db does not cause a crash. --- test/T564-lib-query.sh | 21 + 1 file changed, 21 insertions(+) diff --git a/test/T564-lib-query.sh b/test/T564-lib-query.sh index ea176191..14e47cfb 100755 --- a/test/T564-lib-query.sh +++ b/test/T564-lib-query.sh @@ -99,4 +99,25 @@ SUCCESS EOF test_expect_equal_file EXPECTED OUTPUT +test_begin_subtest "roundtrip sort on closed db" +cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} +{ +notmuch_query_t *query; +const char *str = "id:1258471718-6781-1-git-send-email-dotted...@dottedmag.net"; +notmuch_sort_t sort; + +query = notmuch_query_create (db, str); +EXPECT0(notmuch_database_close (db)); +notmuch_query_set_sort (query, NOTMUCH_SORT_UNSORTED); +sort = notmuch_query_get_sort (query); +printf("%d\n", sort == NOTMUCH_SORT_UNSORTED); +} +EOF +cat < EXPECTED +== stdout == +1 +== stderr == +EOF +test_expect_equal_file EXPECTED OUTPUT + test_done -- 2.27.0 ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
[PATCH 08/10] test: regression test for n_q_search_messages
Exception handling matches notmuch_query_search_threads, at least for this case. --- test/T564-lib-query.sh | 23 +++ 1 file changed, 23 insertions(+) diff --git a/test/T564-lib-query.sh b/test/T564-lib-query.sh index 97729f9a..dda32be7 100755 --- a/test/T564-lib-query.sh +++ b/test/T564-lib-query.sh @@ -162,4 +162,27 @@ Query string was: id:1258471718-6781-1-git-send-email-dotted...@dottedmag.net EOF test_expect_equal_file EXPECTED OUTPUT +test_begin_subtest "search messages on closed db" +cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} +{ +notmuch_query_t *query; +const char *str = "id:1258471718-6781-1-git-send-email-dotted...@dottedmag.net"; +notmuch_messages_t *messages; + +query = notmuch_query_create (db, str); +EXPECT0(notmuch_database_close (db)); +stat = notmuch_query_search_messages (query, ); + +printf("%d\n", stat == NOTMUCH_STATUS_XAPIAN_EXCEPTION); +} +EOF +cat < EXPECTED +== stdout == +1 +== stderr == +A Xapian exception occurred performing query: Database has been closed +Query string was: id:1258471718-6781-1-git-send-email-dotted...@dottedmag.net +EOF +test_expect_equal_file EXPECTED OUTPUT + test_done -- 2.27.0 ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
[PATCH 01/10] test: move notmuch_message_* tests to their own file
This is for consistency with the recently added tests for notmuch_database_*. --- test/T560-lib-error.sh | 359 test/T566-lib-message.sh | 380 +++ 2 files changed, 380 insertions(+), 359 deletions(-) create mode 100755 test/T566-lib-message.sh diff --git a/test/T560-lib-error.sh b/test/T560-lib-error.sh index 908bb9d8..70df292a 100755 --- a/test/T560-lib-error.sh +++ b/test/T560-lib-error.sh @@ -318,363 +318,4 @@ EOF test_expect_equal_file EXPECTED OUTPUT.clean restore_database -cat < c_head2 -#include -#include -#include -int main (int argc, char** argv) -{ - notmuch_database_t *db; - notmuch_status_t stat; - char *msg = NULL; - notmuch_message_t *message = NULL; - const char *id = "1258471718-6781-1-git-send-email-dotted...@dottedmag.net"; - - stat = notmuch_database_open_verbose (argv[1], NOTMUCH_DATABASE_MODE_READ_WRITE, , ); - if (stat != NOTMUCH_STATUS_SUCCESS) { - fprintf (stderr, "error opening database: %d %s\n", stat, msg ? msg : ""); - exit (1); - } - EXPECT0(notmuch_database_find_message (db, id, )); - EXPECT0(notmuch_database_close (db)); -EOF - -test_begin_subtest "Handle getting message-id from closed database" -cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} -{ -const char *id2; -id2=notmuch_message_get_message_id (message); -printf("%d\n%d\n", message != NULL, id2==NULL); -} -EOF -cat < EXPECTED -== stdout == -1 -1 -== stderr == -EOF -test_expect_equal_file EXPECTED OUTPUT - -test_begin_subtest "Handle getting thread-id from closed database" -cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} -{ -const char *id2; -id2=notmuch_message_get_thread_id (message); -printf("%d\n%d\n", message != NULL, id2==NULL); -} -EOF -cat < EXPECTED -== stdout == -1 -1 -== stderr == -EOF -test_expect_equal_file EXPECTED OUTPUT - -test_begin_subtest "Handle getting header from closed database" -cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} -{ -const char *from; -from=notmuch_message_get_header (message, "from"); -printf("%s\n%d\n", id, from == NULL); -} -EOF -cat < EXPECTED -== stdout == -1258471718-6781-1-git-send-email-dotted...@dottedmag.net -1 -== stderr == -EOF -test_expect_equal_file EXPECTED OUTPUT - -# XXX TODO: test on a message from notmuch_thread_get_toplevel_messages -# XXX this test only tests the trivial code path -test_begin_subtest "Handle getting replies from closed database" -cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} -{ -notmuch_messages_t *replies; -replies = notmuch_message_get_replies (message); -printf("%d\n%d\n", message != NULL, replies==NULL); -} -EOF -cat < EXPECTED -== stdout == -1 -1 -== stderr == -EOF -test_expect_equal_file EXPECTED OUTPUT - -test_begin_subtest "Handle getting message filename from closed database" -cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} -{ -const char *filename; -filename = notmuch_message_get_filename (message); -printf("%d\n%d\n", message != NULL, filename == NULL); -} -EOF -cat < EXPECTED -== stdout == -1 -1 -== stderr == -EOF -test_expect_equal_file EXPECTED OUTPUT - -test_begin_subtest "Handle getting all message filenames from closed database" -cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} -{ -notmuch_filenames_t *filenames; -filenames = notmuch_message_get_filenames (message); -printf("%d\n%d\n", message != NULL, filenames == NULL); -} -EOF -cat < EXPECTED -== stdout == -1 -1 -== stderr == -EOF -test_expect_equal_file EXPECTED OUTPUT - -test_begin_subtest "Handle getting ghost flag from closed database" -cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} -{ -notmuch_bool_t result; -result = notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_GHOST); -printf("%d\n%d\n", message != NULL, result == FALSE); -} -EOF -cat < EXPECTED -== stdout == -1 -1 -== stderr == -EOF -test_expect_equal_file EXPECTED OUTPUT - -test_begin_subtest "Handle getting date from closed database" -cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} -{ -time_t result; -result = notmuch_message_get_date (message); -printf("%d\n%d\n", message != NULL, result == 0); -} -EOF -cat < EXPECTED -== stdout == -1 -1 -== stderr == -EOF -test_expect_equal_file EXPECTED OUTPUT - -test_begin_subtest "Handle getting tags from closed database" -cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} -{ -notmuch_tags_t *result; -result = notmuch_message_get_tags (message); -printf("%d\n%d\n", message != NULL, result == NULL); -} -EOF -cat < EXPECTED -== stdout == -1 -1 -== stderr == -EOF -test_expect_equal_file EXPECTED OUTPUT - -test_begin_subtest "Handle counting files from closed database" -cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} -{ -int result; -
[PATCH 04/10] test: regression test for set_omit_excluded
--- test/T564-lib-query.sh | 20 1 file changed, 20 insertions(+) diff --git a/test/T564-lib-query.sh b/test/T564-lib-query.sh index ac08344f..ea176191 100755 --- a/test/T564-lib-query.sh +++ b/test/T564-lib-query.sh @@ -79,4 +79,24 @@ cat < EXPECTED EOF test_expect_equal_file EXPECTED OUTPUT +test_begin_subtest "set omit_excluded on closed db" +cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} +{ +notmuch_query_t *query; +const char *str = "id:1258471718-6781-1-git-send-email-dotted...@dottedmag.net"; + +query = notmuch_query_create (db, str); +EXPECT0(notmuch_database_close (db)); +notmuch_query_set_omit_excluded (query, NOTMUCH_EXCLUDE_ALL); + +printf("SUCCESS\n"); +} +EOF +cat < EXPECTED +== stdout == +SUCCESS +== stderr == +EOF +test_expect_equal_file EXPECTED OUTPUT + test_done -- 2.27.0 ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
[PATCH 09/10] test: regression tests for n_q_count_{messages, threads}
At least these exceptions are caught. --- test/T564-lib-query.sh | 46 ++ 1 file changed, 46 insertions(+) diff --git a/test/T564-lib-query.sh b/test/T564-lib-query.sh index dda32be7..745d28a4 100755 --- a/test/T564-lib-query.sh +++ b/test/T564-lib-query.sh @@ -185,4 +185,50 @@ Query string was: id:1258471718-6781-1-git-send-email-dotted...@dottedmag.net EOF test_expect_equal_file EXPECTED OUTPUT +test_begin_subtest "count messages on closed db" +cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} +{ +notmuch_query_t *query; +const char *str = "id:1258471718-6781-1-git-send-email-dotted...@dottedmag.net"; +unsigned int count; + +query = notmuch_query_create (db, str); +EXPECT0(notmuch_database_close (db)); +stat = notmuch_query_count_messages (query, ); + +printf("%d\n", stat == NOTMUCH_STATUS_XAPIAN_EXCEPTION); +} +EOF +cat < EXPECTED +== stdout == +1 +== stderr == +A Xapian exception occurred performing query: Database has been closed +Query string was: id:1258471718-6781-1-git-send-email-dotted...@dottedmag.net +EOF +test_expect_equal_file EXPECTED OUTPUT + +test_begin_subtest "count threads on closed db" +cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} +{ +notmuch_query_t *query; +const char *str = "id:1258471718-6781-1-git-send-email-dotted...@dottedmag.net"; +unsigned int count; + +query = notmuch_query_create (db, str); +EXPECT0(notmuch_database_close (db)); +stat = notmuch_query_count_threads (query, ); + +printf("%d\n", stat == NOTMUCH_STATUS_XAPIAN_EXCEPTION); +} +EOF +cat < EXPECTED +== stdout == +1 +== stderr == +A Xapian exception occurred performing query: Database has been closed +Query string was: id:1258471718-6781-1-git-send-email-dotted...@dottedmag.net +EOF +test_expect_equal_file EXPECTED OUTPUT + test_done -- 2.27.0 ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
batch 8, API cleanup for exception handling
Apparently no changes are needed to notmuch_query_* to handle exceptions from closed databases. This most likely needs to be applied on top of id:20200719131857.158655-1-da...@tethera.net It certainly needs the changes from id:20200714224119.717845-1-da...@tethera.net, which are not in master yet. ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
[PATCH 10/10] test: regression test for notmuch_query_destroy
As with other void API entries, not crashing counts as success. --- test/T564-lib-query.sh | 20 1 file changed, 20 insertions(+) diff --git a/test/T564-lib-query.sh b/test/T564-lib-query.sh index 745d28a4..50b0a88e 100755 --- a/test/T564-lib-query.sh +++ b/test/T564-lib-query.sh @@ -231,4 +231,24 @@ Query string was: id:1258471718-6781-1-git-send-email-dotted...@dottedmag.net EOF test_expect_equal_file EXPECTED OUTPUT +test_begin_subtest "destroy query with closed db" +cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} +{ +notmuch_query_t *query; +const char *str = "id:1258471718-6781-1-git-send-email-dotted...@dottedmag.net"; + +query = notmuch_query_create (db, str); +EXPECT0(notmuch_database_close (db)); +notmuch_query_destroy (query); + +printf("SUCCESS\n"); +} +EOF +cat < EXPECTED +== stdout == +SUCCESS +== stderr == +EOF +test_expect_equal_file EXPECTED OUTPUT + test_done -- 2.27.0 ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
[PATCH 07/10] test: regression test for n_q_search_threads
At least this exception is caught. --- test/T564-lib-query.sh | 23 +++ 1 file changed, 23 insertions(+) diff --git a/test/T564-lib-query.sh b/test/T564-lib-query.sh index a2f5d731..97729f9a 100755 --- a/test/T564-lib-query.sh +++ b/test/T564-lib-query.sh @@ -139,4 +139,27 @@ cat < EXPECTED EOF test_expect_equal_file EXPECTED OUTPUT +test_begin_subtest "search threads on closed db" +cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} +{ +notmuch_query_t *query; +const char *str = "id:1258471718-6781-1-git-send-email-dotted...@dottedmag.net"; +notmuch_threads_t *threads; + +query = notmuch_query_create (db, str); +EXPECT0(notmuch_database_close (db)); +stat = notmuch_query_search_threads (query, ); + +printf("%d\n", stat == NOTMUCH_STATUS_XAPIAN_EXCEPTION); +} +EOF +cat < EXPECTED +== stdout == +1 +== stderr == +A Xapian exception occurred performing query: Database has been closed +Query string was: id:1258471718-6781-1-git-send-email-dotted...@dottedmag.net +EOF +test_expect_equal_file EXPECTED OUTPUT + test_done -- 2.27.0 ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
[PATCH 06/10] test: add regression test for n_q_add_tag_exclude
This relies on the change to not tear down the auxilary Xapian objects, in particular the query parser, when the database is closed. --- test/T564-lib-query.sh | 19 +++ 1 file changed, 19 insertions(+) diff --git a/test/T564-lib-query.sh b/test/T564-lib-query.sh index 14e47cfb..a2f5d731 100755 --- a/test/T564-lib-query.sh +++ b/test/T564-lib-query.sh @@ -120,4 +120,23 @@ cat < EXPECTED EOF test_expect_equal_file EXPECTED OUTPUT +test_begin_subtest "add tag_exclude on closed db" +cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} +{ +notmuch_query_t *query; +const char *str = "id:1258471718-6781-1-git-send-email-dotted...@dottedmag.net"; + +query = notmuch_query_create (db, str); +EXPECT0(notmuch_database_close (db)); +stat = notmuch_query_add_tag_exclude (query, "spam"); +printf("%d\n", stat == NOTMUCH_STATUS_SUCCESS); +} +EOF +cat < EXPECTED +== stdout == +1 +== stderr == +EOF +test_expect_equal_file EXPECTED OUTPUT + test_done -- 2.27.0 ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org
Re: notmuch.el: notmuch-search: avoid wiping out buffer-local variables
On Tuesday, 2020-07-21 at 16:03:27 -07, Sean Whitton wrote: > Hello, > > I have some code to cycle through a list of searches. The remaining > searches are stored in a buffer-local variable, working something like > this (simplified): > > (defun spw/next-unread-group () >(interactive) >(notmuch-search (car spw/more-unread-groups) >(set (make-local-variable 'spw/more-unread-groups) > (cdr spw/more-unread-groups > > However, my spw/more-unread-groups variable gets wiped out by > notmuch-refresh-this-buffer, because the latter calls > notmuch-search-mode, and major modes wipe out buffer-local variables. > > So far as I can tell that call doesn't actually have any effect when the > mode is already notmuch-search-mode, so may I propose this patch to > support my use case: Seems reasonable. Could you add a comment in the code explaining that it's to avoid clobbering third-party buffer local variables? > diff --git a/emacs/notmuch.el b/emacs/notmuch.el > index dd18f2e1..dcbc1eb2 100644 > --- a/emacs/notmuch.el > +++ b/emacs/notmuch.el > @@ -987,7 +987,8 @@ the configured default sort order." > (if no-display > (set-buffer buffer) >(switch-to-buffer buffer)) > -(notmuch-search-mode) > +(unless (eq major-mode 'notmuch-search-mode) > + (notmuch-search-mode)) > ;; Don't track undo information for this buffer > (set 'buffer-undo-list t) > (set 'notmuch-search-query-string query) > > -- > Sean Whitton > ___ > notmuch mailing list -- notmuch@notmuchmail.org > To unsubscribe send an email to notmuch-le...@notmuchmail.org dme. -- What did you learn today? I learnt nothing. ___ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-le...@notmuchmail.org