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.
This commit is contained in:
David Bremner 2020-07-22 08:19:28 -03:00
parent 1a8060b81f
commit e9867b818b
2 changed files with 44 additions and 25 deletions

View file

@ -96,7 +96,7 @@ static void
_log_xapian_exception (const char *where, notmuch_message_t *message, const Xapian::Error error) { _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_t *notmuch = notmuch_message_get_database (message);
_notmuch_database_log (notmuch, _notmuch_database_log (notmuch,
"A Xapian exception occurred %s retrieving %s : %s\n", "A Xapian exception occurred at %s: %s\n",
where, where,
error.get_msg ().c_str ()); error.get_msg ().c_str ());
notmuch->exception_reported = true; notmuch->exception_reported = true;

View file

@ -345,6 +345,7 @@ cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR}
const char *id2; const char *id2;
id2=notmuch_message_get_message_id (message); id2=notmuch_message_get_message_id (message);
printf("%d\n%d\n", message != NULL, id2==NULL); printf("%d\n%d\n", message != NULL, id2==NULL);
stat = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
} }
EOF EOF
cat <<EOF > EXPECTED cat <<EOF > EXPECTED
@ -352,6 +353,7 @@ cat <<EOF > EXPECTED
1 1
1 1
== stderr == == stderr ==
A Xapian exception occurred at lib/message.cc:XXX: Database has been closed
EOF EOF
test_expect_equal_file EXPECTED OUTPUT test_expect_equal_file EXPECTED OUTPUT
@ -361,6 +363,7 @@ cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR}
const char *id2; const char *id2;
id2=notmuch_message_get_thread_id (message); id2=notmuch_message_get_thread_id (message);
printf("%d\n%d\n", message != NULL, id2==NULL); printf("%d\n%d\n", message != NULL, id2==NULL);
stat = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
} }
EOF EOF
cat <<EOF > EXPECTED cat <<EOF > EXPECTED
@ -368,6 +371,7 @@ cat <<EOF > EXPECTED
1 1
1 1
== stderr == == stderr ==
A Xapian exception occurred at lib/message.cc:XXX: Database has been closed
EOF EOF
test_expect_equal_file EXPECTED OUTPUT test_expect_equal_file EXPECTED OUTPUT
@ -377,6 +381,7 @@ cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR}
const char *from; const char *from;
from=notmuch_message_get_header (message, "from"); from=notmuch_message_get_header (message, "from");
printf("%s\n%d\n", id, from == NULL); printf("%s\n%d\n", id, from == NULL);
stat = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
} }
EOF EOF
cat <<EOF > EXPECTED cat <<EOF > EXPECTED
@ -384,6 +389,7 @@ cat <<EOF > EXPECTED
1258471718-6781-1-git-send-email-dottedmag@dottedmag.net 1258471718-6781-1-git-send-email-dottedmag@dottedmag.net
1 1
== stderr == == stderr ==
A Xapian exception occurred at lib/message.cc:XXX: Database has been closed
EOF EOF
test_expect_equal_file EXPECTED OUTPUT test_expect_equal_file EXPECTED OUTPUT
@ -395,6 +401,7 @@ cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR}
notmuch_messages_t *replies; notmuch_messages_t *replies;
replies = notmuch_message_get_replies (message); replies = notmuch_message_get_replies (message);
printf("%d\n%d\n", message != NULL, replies==NULL); printf("%d\n%d\n", message != NULL, replies==NULL);
stat = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
} }
EOF EOF
cat <<EOF > EXPECTED cat <<EOF > EXPECTED
@ -411,6 +418,7 @@ cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR}
const char *filename; const char *filename;
filename = notmuch_message_get_filename (message); filename = notmuch_message_get_filename (message);
printf("%d\n%d\n", message != NULL, filename == NULL); printf("%d\n%d\n", message != NULL, filename == NULL);
stat = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
} }
EOF EOF
cat <<EOF > EXPECTED cat <<EOF > EXPECTED
@ -418,6 +426,7 @@ cat <<EOF > EXPECTED
1 1
1 1
== stderr == == stderr ==
A Xapian exception occurred at lib/message.cc:XXX: Database has been closed
EOF EOF
test_expect_equal_file EXPECTED OUTPUT test_expect_equal_file EXPECTED OUTPUT
@ -427,6 +436,7 @@ cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR}
notmuch_filenames_t *filenames; notmuch_filenames_t *filenames;
filenames = notmuch_message_get_filenames (message); filenames = notmuch_message_get_filenames (message);
printf("%d\n%d\n", message != NULL, filenames == NULL); printf("%d\n%d\n", message != NULL, filenames == NULL);
stat = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
} }
EOF EOF
cat <<EOF > EXPECTED cat <<EOF > EXPECTED
@ -434,6 +444,7 @@ cat <<EOF > EXPECTED
1 1
1 1
== stderr == == stderr ==
A Xapian exception occurred at lib/message.cc:XXX: Database has been closed
EOF EOF
test_expect_equal_file EXPECTED OUTPUT test_expect_equal_file EXPECTED OUTPUT
@ -443,6 +454,7 @@ cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR}
notmuch_bool_t result; notmuch_bool_t result;
result = notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_GHOST); result = notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_GHOST);
printf("%d\n%d\n", message != NULL, result == FALSE); printf("%d\n%d\n", message != NULL, result == FALSE);
stat = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
} }
EOF EOF
cat <<EOF > EXPECTED cat <<EOF > EXPECTED
@ -450,6 +462,7 @@ cat <<EOF > EXPECTED
1 1
1 1
== stderr == == stderr ==
A Xapian exception occurred at lib/message.cc:XXX: Database has been closed
EOF EOF
test_expect_equal_file EXPECTED OUTPUT test_expect_equal_file EXPECTED OUTPUT
@ -459,6 +472,7 @@ cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR}
time_t result; time_t result;
result = notmuch_message_get_date (message); result = notmuch_message_get_date (message);
printf("%d\n%d\n", message != NULL, result == 0); printf("%d\n%d\n", message != NULL, result == 0);
stat = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
} }
EOF EOF
cat <<EOF > EXPECTED cat <<EOF > EXPECTED
@ -466,6 +480,7 @@ cat <<EOF > EXPECTED
1 1
1 1
== stderr == == stderr ==
A Xapian exception occurred at lib/message.cc:XXX: Database has been closed
EOF EOF
test_expect_equal_file EXPECTED OUTPUT test_expect_equal_file EXPECTED OUTPUT
@ -475,6 +490,7 @@ cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR}
notmuch_tags_t *result; notmuch_tags_t *result;
result = notmuch_message_get_tags (message); result = notmuch_message_get_tags (message);
printf("%d\n%d\n", message != NULL, result == NULL); printf("%d\n%d\n", message != NULL, result == NULL);
stat = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
} }
EOF EOF
cat <<EOF > EXPECTED cat <<EOF > EXPECTED
@ -482,6 +498,7 @@ cat <<EOF > EXPECTED
1 1
1 1
== stderr == == stderr ==
A Xapian exception occurred at lib/message.cc:XXX: Database has been closed
EOF EOF
test_expect_equal_file EXPECTED OUTPUT test_expect_equal_file EXPECTED OUTPUT
@ -491,6 +508,7 @@ cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR}
int result; int result;
result = notmuch_message_count_files (message); result = notmuch_message_count_files (message);
printf("%d\n%d\n", message != NULL, result < 0); printf("%d\n%d\n", message != NULL, result < 0);
stat = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
} }
EOF EOF
cat <<EOF > EXPECTED cat <<EOF > EXPECTED
@ -498,15 +516,15 @@ cat <<EOF > EXPECTED
1 1
1 1
== stderr == == stderr ==
A Xapian exception occurred at lib/message.cc:XXX: Database has been closed
EOF EOF
test_expect_equal_file EXPECTED OUTPUT test_expect_equal_file EXPECTED OUTPUT
test_begin_subtest "Handle adding tag with closed database" test_begin_subtest "Handle adding tag with closed database"
cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR}
{ {
notmuch_status_t status; stat = notmuch_message_add_tag (message, "boom");
status = notmuch_message_add_tag (message, "boom"); printf("%d\n%d\n", message != NULL, stat == NOTMUCH_STATUS_XAPIAN_EXCEPTION);
printf("%d\n%d\n", message != NULL, status == NOTMUCH_STATUS_XAPIAN_EXCEPTION);
} }
EOF EOF
cat <<EOF > EXPECTED cat <<EOF > EXPECTED
@ -514,15 +532,15 @@ cat <<EOF > EXPECTED
1 1
1 1
== stderr == == stderr ==
A Xapian exception occurred at lib/message.cc:XXX: Database has been closed
EOF EOF
test_expect_equal_file EXPECTED OUTPUT test_expect_equal_file EXPECTED OUTPUT
test_begin_subtest "Handle removing tag with closed database" test_begin_subtest "Handle removing tag with closed database"
cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR}
{ {
notmuch_status_t status; stat = notmuch_message_remove_tag (message, "boom");
status = notmuch_message_remove_tag (message, "boom"); printf("%d\n%d\n", message != NULL, stat == NOTMUCH_STATUS_XAPIAN_EXCEPTION);
printf("%d\n%d\n", message != NULL, status == NOTMUCH_STATUS_XAPIAN_EXCEPTION);
} }
EOF EOF
cat <<EOF > EXPECTED cat <<EOF > EXPECTED
@ -530,6 +548,7 @@ cat <<EOF > EXPECTED
1 1
1 1
== stderr == == stderr ==
A Xapian exception occurred at lib/message.cc:XXX: Database has been closed
EOF EOF
test_expect_equal_file EXPECTED OUTPUT test_expect_equal_file EXPECTED OUTPUT
@ -539,6 +558,7 @@ cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR}
notmuch_bool_t is_set = -1; notmuch_bool_t is_set = -1;
is_set = notmuch_message_has_maildir_flag (message, 'S'); is_set = notmuch_message_has_maildir_flag (message, 'S');
printf("%d\n%d\n", message != NULL, is_set == FALSE || is_set == TRUE); printf("%d\n%d\n", message != NULL, is_set == FALSE || is_set == TRUE);
stat = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
} }
EOF EOF
cat <<EOF > EXPECTED cat <<EOF > EXPECTED
@ -546,16 +566,16 @@ cat <<EOF > EXPECTED
1 1
1 1
== stderr == == stderr ==
A Xapian exception occurred at lib/message.cc:XXX: Database has been closed
EOF EOF
test_expect_equal_file EXPECTED OUTPUT test_expect_equal_file EXPECTED OUTPUT
test_begin_subtest "Handle checking maildir flag with closed db (new API)" test_begin_subtest "Handle checking maildir flag with closed db (new API)"
cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR}
{ {
notmuch_status_t status;
notmuch_bool_t out; notmuch_bool_t out;
status = notmuch_message_has_maildir_flag_st (message, 'S', &out); stat = notmuch_message_has_maildir_flag_st (message, 'S', &out);
printf("%d\n%d\n", message != NULL, status == NOTMUCH_STATUS_XAPIAN_EXCEPTION); printf("%d\n%d\n", message != NULL, stat == NOTMUCH_STATUS_XAPIAN_EXCEPTION);
} }
EOF EOF
cat <<EOF > EXPECTED cat <<EOF > EXPECTED
@ -563,15 +583,15 @@ cat <<EOF > EXPECTED
1 1
1 1
== stderr == == stderr ==
A Xapian exception occurred at lib/message.cc:XXX: Database has been closed
EOF EOF
test_expect_equal_file EXPECTED OUTPUT test_expect_equal_file EXPECTED OUTPUT
test_begin_subtest "Handle converting maildir flags to tags with closed db" test_begin_subtest "Handle converting maildir flags to tags with closed db"
cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR}
{ {
notmuch_status_t status; stat = notmuch_message_maildir_flags_to_tags (message);
status = notmuch_message_maildir_flags_to_tags (message); printf("%d\n%d\n", message != NULL, stat == NOTMUCH_STATUS_XAPIAN_EXCEPTION);
printf("%d\n%d\n", message != NULL, status == NOTMUCH_STATUS_XAPIAN_EXCEPTION);
} }
EOF EOF
cat <<EOF > EXPECTED cat <<EOF > EXPECTED
@ -579,15 +599,15 @@ cat <<EOF > EXPECTED
1 1
1 1
== stderr == == stderr ==
A Xapian exception occurred at lib/message.cc:XXX: Database has been closed
EOF EOF
test_expect_equal_file EXPECTED OUTPUT test_expect_equal_file EXPECTED OUTPUT
test_begin_subtest "Handle removing all tags with closed db" test_begin_subtest "Handle removing all tags with closed db"
cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR}
{ {
notmuch_status_t status; stat = notmuch_message_remove_all_tags (message);
status = notmuch_message_remove_all_tags (message); printf("%d\n%d\n", message != NULL, stat == NOTMUCH_STATUS_XAPIAN_EXCEPTION);
printf("%d\n%d\n", message != NULL, status == NOTMUCH_STATUS_XAPIAN_EXCEPTION);
} }
EOF EOF
cat <<EOF > EXPECTED cat <<EOF > EXPECTED
@ -595,15 +615,15 @@ cat <<EOF > EXPECTED
1 1
1 1
== stderr == == stderr ==
A Xapian exception occurred at lib/message.cc:XXX: Database has been closed
EOF EOF
test_expect_equal_file EXPECTED OUTPUT test_expect_equal_file EXPECTED OUTPUT
test_begin_subtest "Handle freezing message with closed db" test_begin_subtest "Handle freezing message with closed db"
cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR}
{ {
notmuch_status_t status; stat = notmuch_message_freeze (message);
status = notmuch_message_freeze (message); printf("%d\n%d\n", message != NULL, stat == NOTMUCH_STATUS_SUCCESS);
printf("%d\n%d\n", message != NULL, status == NOTMUCH_STATUS_SUCCESS);
} }
EOF EOF
cat <<EOF > EXPECTED cat <<EOF > EXPECTED
@ -617,9 +637,8 @@ test_expect_equal_file EXPECTED OUTPUT
test_begin_subtest "Handle thawing message with closed db" test_begin_subtest "Handle thawing message with closed db"
cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR}
{ {
notmuch_status_t status; stat = notmuch_message_thaw (message);
status = notmuch_message_thaw (message); printf("%d\n%d\n", message != NULL, stat == NOTMUCH_STATUS_UNBALANCED_FREEZE_THAW);
printf("%d\n%d\n", message != NULL, status == NOTMUCH_STATUS_UNBALANCED_FREEZE_THAW);
} }
EOF EOF
cat <<EOF > EXPECTED cat <<EOF > EXPECTED
@ -664,9 +683,8 @@ test_expect_equal_file EXPECTED OUTPUT
test_begin_subtest "Handle reindexing message with closed db" test_begin_subtest "Handle reindexing message with closed db"
cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR}
{ {
notmuch_status_t status; stat = notmuch_message_reindex (message, NULL);
status = notmuch_message_reindex (message, NULL); printf("%d\n%d\n", message != NULL, stat == NOTMUCH_STATUS_XAPIAN_EXCEPTION);
printf("%d\n%d\n", message != NULL, status == NOTMUCH_STATUS_XAPIAN_EXCEPTION);
} }
EOF EOF
cat <<EOF > EXPECTED cat <<EOF > EXPECTED
@ -674,6 +692,7 @@ cat <<EOF > EXPECTED
1 1
1 1
== stderr == == stderr ==
A Xapian exception occurred at lib/message.cc:XXX: Database has been closed
EOF EOF
test_expect_equal_file EXPECTED OUTPUT test_expect_equal_file EXPECTED OUTPUT