unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Bremner <david@tethera.net>
To: notmuch@notmuchmail.org, eg@gaute.vetsj.com
Subject: [PATCH 1/4] test: add known broken test for uncaught DatabaseModifiedError
Date: Fri, 24 Feb 2017 23:45:10 -0400	[thread overview]
Message-ID: <20170225034513.19427-2-david@tethera.net> (raw)
In-Reply-To: <20170225034513.19427-1-david@tethera.net>

There are several of these to track down, but one that is in quite a
few code paths is _notmuch_message_ensure_metadata.
---
 test/T640-database-modified.sh | 60 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)
 create mode 100755 test/T640-database-modified.sh

diff --git a/test/T640-database-modified.sh b/test/T640-database-modified.sh
new file mode 100755
index 00000000..41869eaa
--- /dev/null
+++ b/test/T640-database-modified.sh
@@ -0,0 +1,60 @@
+#!/usr/bin/env bash
+test_description="DatabaseModifiedError handling"
+. ./test-lib.sh || exit 1
+
+add_email_corpus
+
+test_begin_subtest "catching DatabaseModifiedError in _notmuch_message_ensure_metadata"
+test_subtest_known_broken
+test_C ${MAIL_DIR} <<'EOF'
+#include <unistd.h>
+#include <stdlib.h>
+#include <notmuch-test.h>
+#include <talloc.h>
+int
+main (int argc, char **argv)
+{
+    pid_t child;
+    const char *path = argv[1];
+
+    notmuch_database_t *rw_db, *ro_db;
+    notmuch_messages_t *messages;
+    notmuch_message_t *message, *ro_message;
+    notmuch_query_t *query;
+    notmuch_tags_t *tags;
+
+    EXPECT0 (notmuch_database_open (path, NOTMUCH_DATABASE_MODE_READ_ONLY, &ro_db));
+    EXPECT0 (notmuch_database_find_message (ro_db, "4EFC743A.3060609@april.org", &ro_message));
+
+    EXPECT0 (notmuch_database_open (path, NOTMUCH_DATABASE_MODE_READ_WRITE, &rw_db));
+    query = notmuch_query_create(rw_db, "");
+    EXPECT0 (notmuch_query_search_messages_st (query, &messages));
+
+    for (int count=0;
+	 notmuch_messages_valid (messages);
+	 notmuch_messages_move_to_next (messages), count++) {
+	message = notmuch_messages_get (messages);
+	for (int i=0; i<200; i++) {
+	    char *tag_str = talloc_asprintf(rw_db, "%d", i);
+	    EXPECT0 (notmuch_message_add_tag (message, tag_str));
+	    talloc_free (tag_str);
+	}
+    }
+
+    notmuch_database_close (rw_db);
+
+    tags = notmuch_message_get_tags (ro_message);
+    if (tags)
+	printf("SUCCESS\n");
+    return 0;
+}
+EOF
+
+cat <<'EOF' >EXPECTED
+== stdout ==
+SUCCESS
+== stderr ==
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
+test_done
-- 
2.11.0

  reply	other threads:[~2017-02-25  3:45 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-25  3:45 v1 _notmuch_message_ensure_metadata exception handling David Bremner
2017-02-25  3:45 ` David Bremner [this message]
2017-02-25 18:49   ` [PATCH 1/4] test: add known broken test for uncaught DatabaseModifiedError Jani Nikula
2017-02-25 20:08     ` David Bremner
2017-02-25  3:45 ` [PATCH 2/4] lib: add notmuch_database_reopen David Bremner
2017-02-25 18:33   ` Jani Nikula
2017-02-25 20:11     ` David Bremner
2017-02-25  3:45 ` [PATCH 3/4] lib: handle DatabaseModifiedError in _n_message_ensure_metadata David Bremner
2017-02-25 18:42   ` Jani Nikula
2017-02-25 20:21     ` David Bremner
2017-02-25 20:39       ` Jani Nikula
2017-02-25  3:45 ` [PATCH 4/4] lib/message.cc: use view number to invalidate cached metadata David Bremner
2017-02-25 18:44   ` Jani Nikula

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170225034513.19427-2-david@tethera.net \
    --to=david@tethera.net \
    --cc=eg@gaute.vetsj.com \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).