Re: [PATCH 1/3] gitignore: Ignore generated sphinx.config

2020-07-24 Thread Jonas Bernoulli
David Bremner  writes:
> I don't think the patch dos what you think it does?

Indeed.  I'll post the correct commit in v2 but will
wait for the rest of the review before posting that.
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


Re: [PATCH 1/3] gitignore: Ignore generated sphinx.config

2020-07-24 Thread David Bremner
Jonas Bernoulli  writes:

> ---
>  sphinx.config | 4 
>  1 file changed, 4 insertions(+)
>  create mode 100644 sphinx.config
>
> diff --git a/sphinx.config b/sphinx.config
> new file mode 100644
> index ..207614b4
> --- /dev/null
> +++ b/sphinx.config
> @@ -0,0 +1,4 @@
> +# Generated by configure, run from doc/conf.py
> +tags.add('WITH_EMACS')
> +tags.add('WITH_PYTHON')
> +rsti_dir = '/home/jonas/.emacs.d/lib/notmuch/emacs'

I don't think the patch dos what you think it does?

cheers,

d
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 3/3] test: Explicitly state that we want to sign with sender

2020-07-24 Thread Jonas Bernoulli
Since Emacs 27 'mml-secure-epg-sign' errors out if we don't opt-in to
signing as the sender using 'mml-secure-openpgp-sign-with-sender'.
---
 test/test-lib.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/test/test-lib.sh b/test/test-lib.sh
index 8c331b88..90e26639 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -414,7 +414,8 @@ emacs_fcc_message ()
   (message-goto-body)
   (insert \"${body}\")
   $*
-  (notmuch-mua-send-and-exit))" || return 1
+  (let ((mml-secure-openpgp-sign-with-sender t))
+(notmuch-mua-send-and-exit)))" || return 1
 notmuch new $nmn_args >/dev/null
 }
 
-- 
2.26.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 2/3] test: Deal with Emacs 27 switching to lexical scope by default

2020-07-24 Thread Jonas Bernoulli
Starting with Emacs 27 undeclared variables in evaluated interactive
code uses lexical scope.  This includes code passed with '--eval' as
we do in the Emacs tests, which also happen to assume dynamic scope.

This can affect variables defined by libraries that we use.  We let-
bind such variables to change the behavior of functions which we then
call with these bindings in effect.  If these libraries are not loaded
beforehand, then the bindings are lexical and fail to have the effect
we intended.

At this time only 'smtpmail' has to be loaded explicitly (for the
variables let-bound in emacs_deliver_message and emacs_fcc_message).

'message' doesn't have to be loaded explicitly, because loading
'notmuch' (in 'run_emacs') already takes care of that, indirectly.

Our own testing-only variables also have to be declared explicitly.
We should have done that anyway, but because of how and where these
variables are used it was very easy to overlook that (i.e. it isn't
something the byte-compiler ever looks at).  Not so in Emacs 27
anymore; here this oversight caused four tests to fail.
---
 test/test-lib.el | 9 +
 1 file changed, 9 insertions(+)

diff --git a/test/test-lib.el b/test/test-lib.el
index b47b388e..579a20d5 100644
--- a/test/test-lib.el
+++ b/test/test-lib.el
@@ -22,6 +22,12 @@
 
 (require 'cl-lib)
 
+;; Ensure that the dynamic variables that are defined by this library
+;; are defined by the time that we let-bind them.  This is needed
+;; because starting with Emacs 27 undeclared variables in evaluated
+;; interactive code (such as our tests) use lexical scope.
+(require 'smtpmail)
+
 ;; `read-file-name' by default uses `completing-read' function to read
 ;; user input.  It does not respect `standard-input' variable which we
 ;; use in tests to provide user input.  So replace it with a plain
@@ -113,6 +119,9 @@ (defun add-hook-counter (hook)
 (add-hook-counter 'notmuch-hello-mode-hook)
 (add-hook-counter 'notmuch-hello-refresh-hook)
 
+(defvar notmuch-hello-mode-hook-counter -100)
+(defvar notmuch-hello-refresh-hook-counter -100)
+
 (defadvice notmuch-search-process-filter (around pessimal activate disable)
   "Feed notmuch-search-process-filter one character at a time."
   (let ((string (ad-get-arg 1)))
-- 
2.26.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 0/3] Adjust test for changes in Emacs 27

2020-07-24 Thread Jonas Bernoulli
Without these changes many tests fail on upcoming Emacs 27.1.
The details are in the commit messages.

 Cheers,

Jonas Bernoulli (3):
  gitignore: Ignore generated sphinx.config
  test: Deal with Emacs 27 switching to lexical scope by default
  test: Explicitly state that we want to sign with sender

 sphinx.config| 4 
 test/test-lib.el | 9 +
 test/test-lib.sh | 3 ++-
 3 files changed, 15 insertions(+), 1 deletion(-)
 create mode 100644 sphinx.config

-- 
2.26.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 1/3] gitignore: Ignore generated sphinx.config

2020-07-24 Thread Jonas Bernoulli
---
 sphinx.config | 4 
 1 file changed, 4 insertions(+)
 create mode 100644 sphinx.config

diff --git a/sphinx.config b/sphinx.config
new file mode 100644
index ..207614b4
--- /dev/null
+++ b/sphinx.config
@@ -0,0 +1,4 @@
+# Generated by configure, run from doc/conf.py
+tags.add('WITH_EMACS')
+tags.add('WITH_PYTHON')
+rsti_dir = '/home/jonas/.emacs.d/lib/notmuch/emacs'
-- 
2.26.0
___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


batch 9: API cleanup for exception handling

2020-07-24 Thread David Bremner
This is another batch where everything seems to just work (TM), which
is great because no API changes are needed.

___
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org


[PATCH 5/8] test: add regression tests for n_t_get_{authors, subject}

2020-07-24 Thread David Bremner
This is returning explicitely cached data, so no database access is needed.
---
 test/T568-lib-thread.sh | 33 +
 1 file changed, 33 insertions(+)

diff --git a/test/T568-lib-thread.sh b/test/T568-lib-thread.sh
index c7d4f26b..0f9fa443 100755
--- a/test/T568-lib-thread.sh
+++ b/test/T568-lib-thread.sh
@@ -198,4 +198,37 @@ yunaayketfm@aiko.keithp.com
 EOF
 test_expect_equal_file EXPECTED OUTPUT
 
+test_begin_subtest "get authors from closed database"
+cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
+{
+const char *authors;
+authors = notmuch_thread_get_authors (thread);
+printf("%d\n%s\n", thread != NULL, authors);
+}
+EOF
+cat < EXPECTED
+== stdout ==
+1
+Lars Kellogg-Stedman, Mikhail Gusarov, Keith Packard, Carl Worth
+== stderr ==
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
+test_begin_subtest "get subject from closed database"
+cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
+{
+const char *subject;
+subject = notmuch_thread_get_subject (thread);
+printf("%d\n%s\n", thread != NULL, subject);
+}
+EOF
+cat < EXPECTED
+== stdout ==
+1
+[notmuch] Working with Maildir storage?
+== 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 4/8] test: add regression test for n_t_get_messages

2020-07-24 Thread David Bremner
This is similar to the case of toplevel messages. Currently everything
is cached, so no database access is necessary. This might change in
the future, but it should not crash in either case.
---
 test/T568-lib-thread.sh | 26 ++
 1 file changed, 26 insertions(+)

diff --git a/test/T568-lib-thread.sh b/test/T568-lib-thread.sh
index 4703950b..c7d4f26b 100755
--- a/test/T568-lib-thread.sh
+++ b/test/T568-lib-thread.sh
@@ -172,4 +172,30 @@ cat < EXPECTED
 EOF
 test_expect_equal_file EXPECTED OUTPUT
 
+test_begin_subtest "iterate over all messages with closed database"
+cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
+{
+  notmuch_messages_t *messages;
+  for (messages = notmuch_thread_get_messages (thread);
+   notmuch_messages_valid (messages);
+   notmuch_messages_move_to_next (messages)) {
+notmuch_message_t *message = notmuch_messages_get (messages);
+const char *mid = notmuch_message_get_message_id (message);
+printf("%s\n", mid);
+  }
+}
+EOF
+cat < EXPECTED
+== stdout ==
+20091117190054.gu3...@dottiness.seas.harvard.edu
+87iqd9rn3l.fsf@vertex.dottedmag
+20091117203301.gv3...@dottiness.seas.harvard.edu
+87fx8can9z.fsf@vertex.dottedmag
+yunaayketfm@aiko.keithp.com
+20091118005040.ga25...@dottiness.seas.harvard.edu
+87ocn0qh6d@yoom.home.cworth.org
+== 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 6/8] test: add regression tests for oldest and newest dates

2020-07-24 Thread David Bremner
These are strictly to watch for crashes, so don't be too fussy about
the actual timestamps.
---
 test/T568-lib-thread.sh | 32 
 1 file changed, 32 insertions(+)

diff --git a/test/T568-lib-thread.sh b/test/T568-lib-thread.sh
index 0f9fa443..3eb28f3b 100755
--- a/test/T568-lib-thread.sh
+++ b/test/T568-lib-thread.sh
@@ -230,5 +230,37 @@ cat < EXPECTED
 EOF
 test_expect_equal_file EXPECTED OUTPUT
 
+test_begin_subtest "oldest date from closed database"
+cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
+{
+time_t stamp;
+stamp = notmuch_thread_get_oldest_date (thread);
+printf("%d\n%d\n", thread != NULL, stamp > 0);
+}
+EOF
+cat < EXPECTED
+== stdout ==
+1
+1
+== stderr ==
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
+test_begin_subtest "newest date from closed database"
+cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
+{
+time_t stamp;
+stamp = notmuch_thread_get_newest_date (thread);
+printf("%d\n%d\n", thread != NULL, stamp > 0);
+}
+EOF
+cat < EXPECTED
+== stdout ==
+1
+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 2/8] test: add regression test for n_thread_get_total_{messages,files}

2020-07-24 Thread David Bremner
This is returning cached info, so does not need to access the (closed)
database.
---
 test/T568-lib-thread.sh | 32 
 1 file changed, 32 insertions(+)

diff --git a/test/T568-lib-thread.sh b/test/T568-lib-thread.sh
index 00755834..5816cfbc 100755
--- a/test/T568-lib-thread.sh
+++ b/test/T568-lib-thread.sh
@@ -60,4 +60,36 @@ cat < EXPECTED
 EOF
 test_expect_equal_file EXPECTED OUTPUT
 
+test_begin_subtest "get total messages with closed database"
+cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
+{
+int count;
+count = notmuch_thread_get_total_messages (thread);
+printf("%d\n%d\n", thread != NULL, count);
+}
+EOF
+cat < EXPECTED
+== stdout ==
+1
+7
+== stderr ==
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
+test_begin_subtest "get total files with closed database"
+cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
+{
+int count;
+count = notmuch_thread_get_total_files (thread);
+printf("%d\n%d\n", thread != NULL, count);
+}
+EOF
+cat < EXPECTED
+== stdout ==
+1
+7
+== 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 8/8] test: destroy thread from closed database

2020-07-24 Thread David Bremner
Check for (non)-crash.
---
 test/T568-lib-thread.sh | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/test/T568-lib-thread.sh b/test/T568-lib-thread.sh
index 82e4ecb8..66066854 100755
--- a/test/T568-lib-thread.sh
+++ b/test/T568-lib-thread.sh
@@ -285,5 +285,19 @@ unread
 EOF
 test_expect_equal_file EXPECTED OUTPUT
 
+test_begin_subtest "destroy thread with closed database"
+cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
+{
+time_t stamp;
+notmuch_thread_destroy (thread);
+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 7/8] test: regression test for n_thread_get_tags

2020-07-24 Thread David Bremner
Code is taken from the API docs, with the twist that the underlying
database is closed. Not crashing is the main point.
---
 test/T568-lib-thread.sh | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/test/T568-lib-thread.sh b/test/T568-lib-thread.sh
index 3eb28f3b..82e4ecb8 100755
--- a/test/T568-lib-thread.sh
+++ b/test/T568-lib-thread.sh
@@ -262,5 +262,28 @@ cat < EXPECTED
 EOF
 test_expect_equal_file EXPECTED OUTPUT
 
+test_begin_subtest "iterate tags from closed database"
+cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
+{
+  notmuch_tags_t *tags;
+  const char *tag;
+  for (tags = notmuch_thread_get_tags (thread);
+   notmuch_tags_valid (tags);
+   notmuch_tags_move_to_next (tags))
+{
+  tag = notmuch_tags_get (tags);
+  printf ("%s\n", tag);
+}
+}
+EOF
+cat < EXPECTED
+== stdout ==
+inbox
+signed
+unread
+== 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 1/8] test: regression test for n_t_get_thread_id

2020-07-24 Thread David Bremner
This is just cached data, so as long as we don't prematurely free
anything, it should be fine.
---
 test/T568-lib-thread.sh | 63 +
 1 file changed, 63 insertions(+)
 create mode 100755 test/T568-lib-thread.sh

diff --git a/test/T568-lib-thread.sh b/test/T568-lib-thread.sh
new file mode 100755
index ..00755834
--- /dev/null
+++ b/test/T568-lib-thread.sh
@@ -0,0 +1,63 @@
+#!/usr/bin/env bash
+test_description="API tests for notmuch_thread_*"
+
+. $(dirname "$0")/test-lib.sh || exit 1
+
+add_email_corpus
+
+test_begin_subtest "building database"
+test_expect_success "NOTMUCH_NEW"
+
+cat <<'EOF' > c_tail
+   if (stat) {
+   const char *stat_str = notmuch_database_status_string (db);
+   if (stat_str)
+   fputs (stat_str, stderr);
+}
+
+}
+EOF
+
+cat < c_head
+#include 
+#include 
+#include 
+int main (int argc, char** argv)
+{
+   notmuch_database_t *db;
+   notmuch_status_t stat;
+   char *msg = NULL;
+   notmuch_thread_t *thread = NULL;
+   notmuch_threads_t *threads = NULL;
+   notmuch_query_t *query = NULL;
+   const char *id = "thread:0009";
+
+   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);
+   }
+
+   query = notmuch_query_create (db, id);
+   EXPECT0(notmuch_query_search_threads (query, ));
+   thread = notmuch_threads_get (threads);
+   EXPECT0(notmuch_database_close (db));
+EOF
+
+test_begin_subtest "get thread-id from closed database"
+cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
+{
+const char *id2;
+id2 = notmuch_thread_get_thread_id (thread);
+printf("%d\n%s\n", thread != NULL, id2);
+}
+EOF
+cat < EXPECTED
+== stdout ==
+1
+0009
+== 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 3/8] test: add regression tests for n_thread_get_toplevel_messages

2020-07-24 Thread David Bremner
Include a test for the previously omitted non-trivial code path for
notmuch_thread_get_replies.
---
 test/T566-lib-message.sh |  1 -
 test/T568-lib-thread.sh  | 80 
 2 files changed, 80 insertions(+), 1 deletion(-)

diff --git a/test/T566-lib-message.sh b/test/T566-lib-message.sh
index 7a351725..4c9fc0df 100755
--- a/test/T566-lib-message.sh
+++ b/test/T566-lib-message.sh
@@ -93,7 +93,6 @@ A Xapian exception occurred at lib/message.cc:XXX: Database 
has been closed
 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_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
diff --git a/test/T568-lib-thread.sh b/test/T568-lib-thread.sh
index 5816cfbc..4703950b 100755
--- a/test/T568-lib-thread.sh
+++ b/test/T568-lib-thread.sh
@@ -92,4 +92,84 @@ cat < EXPECTED
 EOF
 test_expect_equal_file EXPECTED OUTPUT
 
+test_begin_subtest "get top level messages with closed database"
+cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
+{
+notmuch_messages_t *messages;
+messages = notmuch_thread_get_toplevel_messages (thread);
+printf("%d\n%d\n", thread != NULL, messages != NULL);
+}
+EOF
+cat < EXPECTED
+== stdout ==
+1
+1
+== stderr ==
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
+test_begin_subtest "iterate over level messages with closed database"
+cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
+{
+  notmuch_messages_t *messages;
+  for (messages = notmuch_thread_get_toplevel_messages (thread);
+   notmuch_messages_valid (messages);
+   notmuch_messages_move_to_next (messages)) {
+notmuch_message_t *message = notmuch_messages_get (messages);
+const char *mid = notmuch_message_get_message_id (message);
+printf("%s\n", mid);
+  }
+}
+EOF
+cat < EXPECTED
+== stdout ==
+20091117190054.gu3...@dottiness.seas.harvard.edu
+== stderr ==
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
+test_begin_subtest "iterate over level messages with closed database"
+cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
+{
+  notmuch_messages_t *messages;
+  for (messages = notmuch_thread_get_toplevel_messages (thread);
+   notmuch_messages_valid (messages);
+   notmuch_messages_move_to_next (messages)) {
+notmuch_message_t *message = notmuch_messages_get (messages);
+const char *mid = notmuch_message_get_message_id (message);
+printf("%s\n", mid);
+  }
+}
+EOF
+cat < EXPECTED
+== stdout ==
+20091117190054.gu3...@dottiness.seas.harvard.edu
+== stderr ==
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
+test_begin_subtest "iterate over replies with closed database"
+cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
+{
+  notmuch_messages_t *messages = notmuch_thread_get_toplevel_messages 
(thread);
+  notmuch_message_t *message = notmuch_messages_get (messages);
+  notmuch_messages_t *replies;
+  for (replies = notmuch_message_get_replies (message);
+   notmuch_messages_valid (replies);
+   notmuch_messages_move_to_next (replies)) {
+notmuch_message_t *message = notmuch_messages_get (replies);
+const char *mid = notmuch_message_get_message_id (message);
+
+printf("%s\n", mid);
+  }
+}
+EOF
+cat < EXPECTED
+== stdout ==
+87iqd9rn3l.fsf@vertex.dottedmag
+87ocn0qh6d@yoom.home.cworth.org
+== 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