From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id UNtxK4YsGF8OCgAA0tVLHw (envelope-from ) for ; Wed, 22 Jul 2020 12:09:42 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id gA4YJ4YsGF9sdQAAbx9fmQ (envelope-from ) for ; Wed, 22 Jul 2020 12:09:42 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [IPv6:2607:5300:201:3100::1657]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (2048 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id F0D9A9400BF for ; Wed, 22 Jul 2020 12:09:41 +0000 (UTC) Received: from [144.217.243.247] (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 9049426BD8; Wed, 22 Jul 2020 08:09:30 -0400 (EDT) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id 701EF1F70F for ; Wed, 22 Jul 2020 08:09:27 -0400 (EDT) Received: by fethera.tethera.net (Postfix, from userid 1001) id 66F2760AB7; Wed, 22 Jul 2020 08:09:27 -0400 (EDT) Received: (nullmailer pid 472614 invoked by uid 1000); Wed, 22 Jul 2020 12:09:24 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 2/2] lib: fix exception messages for n_m_message_* Date: Wed, 22 Jul 2020 09:09:05 -0300 Message-Id: <20200722120905.472562-2-david@tethera.net> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200722120905.472562-1-david@tethera.net> References: <20200722120905.472562-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: 65JLTZIGPSZS43M65MW7NQEJEJYVJJUY X-Message-ID-Hash: 65JLTZIGPSZS43M65MW7NQEJEJYVJJUY X-MailFrom: bremner@tethera.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Spam-Score: 1.53 X-TUID: xqMCOXrkEyMl 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-dottedmag@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); printf("%d\n%d\n", message != NULL, result == NULL); + stat = NOTMUCH_STATUS_XAPIAN_EXCEPTION; } EOF cat < EXPECTED @@ -482,6 +498,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 @@ -491,6 +508,7 @@ cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} int result; result = notmuch_message_count_files (message); printf("%d\n%d\n", message != NULL, result < 0); + stat = NOTMUCH_STATUS_XAPIAN_EXCEPTION; } EOF cat < EXPECTED @@ -498,15 +516,15 @@ 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 test_begin_subtest "Handle adding tag with closed database" cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} { - notmuch_status_t status; - status = notmuch_message_add_tag (message, "boom"); - printf("%d\n%d\n", message != NULL, status == NOTMUCH_STATUS_XAPIAN_EXCEPTION); + stat = notmuch_message_add_tag (message, "boom"); + printf("%d\n%d\n", message != NULL, stat == NOTMUCH_STATUS_XAPIAN_EXCEPTION); } EOF cat < EXPECTED @@ -514,15 +532,15 @@ 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 test_begin_subtest "Handle removing tag with closed database" cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} { - notmuch_status_t status; - status = notmuch_message_remove_tag (message, "boom"); - printf("%d\n%d\n", message != NULL, status == NOTMUCH_STATUS_XAPIAN_EXCEPTION); + stat = notmuch_message_remove_tag (message, "boom"); + printf("%d\n%d\n", message != NULL, stat == NOTMUCH_STATUS_XAPIAN_EXCEPTION); } EOF cat < EXPECTED @@ -530,6 +548,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 @@ -539,6 +558,7 @@ cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} notmuch_bool_t is_set = -1; is_set = notmuch_message_has_maildir_flag (message, 'S'); printf("%d\n%d\n", message != NULL, is_set == FALSE || is_set == TRUE); + stat = NOTMUCH_STATUS_XAPIAN_EXCEPTION; } EOF cat < EXPECTED @@ -546,16 +566,16 @@ 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 test_begin_subtest "Handle checking maildir flag with closed db (new API)" cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} { - notmuch_status_t status; notmuch_bool_t out; - status = notmuch_message_has_maildir_flag_st (message, 'S', &out); - printf("%d\n%d\n", message != NULL, status == NOTMUCH_STATUS_XAPIAN_EXCEPTION); + stat = notmuch_message_has_maildir_flag_st (message, 'S', &out); + printf("%d\n%d\n", message != NULL, stat == NOTMUCH_STATUS_XAPIAN_EXCEPTION); } EOF cat < EXPECTED @@ -563,15 +583,15 @@ 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 test_begin_subtest "Handle converting maildir flags to tags with closed db" cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} { - notmuch_status_t status; - status = notmuch_message_maildir_flags_to_tags (message); - printf("%d\n%d\n", message != NULL, status == NOTMUCH_STATUS_XAPIAN_EXCEPTION); + stat = notmuch_message_maildir_flags_to_tags (message); + printf("%d\n%d\n", message != NULL, stat == NOTMUCH_STATUS_XAPIAN_EXCEPTION); } EOF cat < EXPECTED @@ -579,15 +599,15 @@ 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 test_begin_subtest "Handle removing all tags with closed db" cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} { - notmuch_status_t status; - status = notmuch_message_remove_all_tags (message); - printf("%d\n%d\n", message != NULL, status == NOTMUCH_STATUS_XAPIAN_EXCEPTION); + stat = notmuch_message_remove_all_tags (message); + printf("%d\n%d\n", message != NULL, stat == NOTMUCH_STATUS_XAPIAN_EXCEPTION); } EOF cat < EXPECTED @@ -595,15 +615,15 @@ 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 test_begin_subtest "Handle freezing message with closed db" cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} { - notmuch_status_t status; - status = notmuch_message_freeze (message); - printf("%d\n%d\n", message != NULL, status == NOTMUCH_STATUS_SUCCESS); + stat = notmuch_message_freeze (message); + printf("%d\n%d\n", message != NULL, stat == NOTMUCH_STATUS_SUCCESS); } EOF cat < EXPECTED @@ -617,9 +637,8 @@ test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "Handle thawing message with closed db" cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} { - notmuch_status_t status; - status = notmuch_message_thaw (message); - printf("%d\n%d\n", message != NULL, status == NOTMUCH_STATUS_UNBALANCED_FREEZE_THAW); + stat = notmuch_message_thaw (message); + printf("%d\n%d\n", message != NULL, stat == NOTMUCH_STATUS_UNBALANCED_FREEZE_THAW); } EOF cat < EXPECTED @@ -664,9 +683,8 @@ test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "Handle reindexing message with closed db" cat c_head2 - c_tail <<'EOF' | test_C ${MAIL_DIR} { - notmuch_status_t status; - status = notmuch_message_reindex (message, NULL); - printf("%d\n%d\n", message != NULL, status == NOTMUCH_STATUS_XAPIAN_EXCEPTION); + stat = notmuch_message_reindex (message, NULL); + printf("%d\n%d\n", message != NULL, stat == NOTMUCH_STATUS_XAPIAN_EXCEPTION); } EOF cat < EXPECTED @@ -674,6 +692,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 -- 2.27.0