2 test_description="DatabaseModifiedError handling"
3 . ./test-lib.sh || exit 1
5 # add enough messages to trigger the exception
8 test_begin_subtest "catching DatabaseModifiedError in _notmuch_message_ensure_metadata"
9 test_subtest_known_broken
10 # it seems to need to be an early document to trigger the exception
11 first_id=$(notmuch search --output=messages '*'| head -1 | sed s/^id://)
13 test_C ${MAIL_DIR} <<EOF
16 #include <notmuch-test.h>
20 main (int argc, char **argv)
22 const char *path = argv[1];
24 notmuch_database_t *rw_db, *ro_db;
25 notmuch_messages_t *messages;
26 notmuch_message_t *message, *ro_message;
27 notmuch_query_t *query;
30 EXPECT0 (notmuch_database_open (path, NOTMUCH_DATABASE_MODE_READ_ONLY, &ro_db));
33 EXPECT0 (notmuch_database_find_message (ro_db, "${first_id}", &ro_message));
36 EXPECT0 (notmuch_database_open (path, NOTMUCH_DATABASE_MODE_READ_WRITE, &rw_db));
37 query = notmuch_query_create(rw_db, "");
38 EXPECT0 (notmuch_query_search_messages_st (query, &messages));
41 notmuch_messages_valid (messages);
42 notmuch_messages_move_to_next (messages), count++) {
43 message = notmuch_messages_get (messages);
44 for (int i=0; i<200; i++) {
45 char *tag_str = talloc_asprintf(rw_db, "%d", i);
46 EXPECT0 (notmuch_message_add_tag (message, tag_str));
47 talloc_free (tag_str);
51 notmuch_database_close (rw_db);
53 tags = notmuch_message_get_tags (ro_message);
65 test_expect_equal_file EXPECTED OUTPUT