* [PATCH 1/2] test: sanitize line numbers in exception reports
@ 2020-07-22 12:09 David Bremner
2020-07-22 12:09 ` [PATCH 2/2] lib: fix exception messages for n_m_message_* David Bremner
2020-07-23 10:11 ` [PATCH 1/2] test: sanitize line numbers in exception reports David Bremner
0 siblings, 2 replies; 3+ messages in thread
From: David Bremner @ 2020-07-22 12:09 UTC (permalink / raw)
To: notmuch; +Cc: David Bremner
Prevent test suite churn when reported line numbers change.
---
test/test-lib.sh | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/test/test-lib.sh b/test/test-lib.sh
index 7424881e..8c331b88 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -619,6 +619,11 @@ print(msg.as_string(False))
' "$@"
}
+notmuch_exception_sanitize ()
+{
+ perl -pe 's/(A Xapian exception occurred at .*[.]cc?):([0-9]*)/\1:XXX/'
+}
+
notmuch_search_sanitize ()
{
perl -pe 's/("?thread"?: ?)("?)................("?)/\1\2XXX\3/'
@@ -1093,7 +1098,7 @@ test_C () {
echo "== stdout ==" > OUTPUT.stdout
echo "== stderr ==" > OUTPUT.stderr
./${exec_file} "$@" 1>>OUTPUT.stdout 2>>OUTPUT.stderr
- notmuch_dir_sanitize OUTPUT.stdout OUTPUT.stderr > OUTPUT
+ notmuch_dir_sanitize OUTPUT.stdout OUTPUT.stderr | notmuch_exception_sanitize > OUTPUT
}
make_shim () {
--
2.27.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] lib: fix exception messages for n_m_message_*
2020-07-22 12:09 [PATCH 1/2] test: sanitize line numbers in exception reports David Bremner
@ 2020-07-22 12:09 ` David Bremner
2020-07-23 10:11 ` [PATCH 1/2] test: sanitize line numbers in exception reports David Bremner
1 sibling, 0 replies; 3+ messages in thread
From: David Bremner @ 2020-07-22 12:09 UTC (permalink / raw)
To: notmuch; +Cc: David Bremner
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 <<EOF > EXPECTED
@@ -352,6 +353,7 @@ cat <<EOF > 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 <<EOF > EXPECTED
@@ -368,6 +371,7 @@ cat <<EOF > 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 <<EOF > EXPECTED
@@ -384,6 +389,7 @@ cat <<EOF > 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 <<EOF > 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 <<EOF > EXPECTED
@@ -418,6 +426,7 @@ cat <<EOF > 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 <<EOF > EXPECTED
@@ -434,6 +444,7 @@ cat <<EOF > 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 <<EOF > EXPECTED
@@ -450,6 +462,7 @@ cat <<EOF > 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 <<EOF > EXPECTED
@@ -466,6 +480,7 @@ cat <<EOF > 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 <<EOF > EXPECTED
@@ -482,6 +498,7 @@ cat <<EOF > 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 <<EOF > EXPECTED
@@ -498,15 +516,15 @@ cat <<EOF > 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 <<EOF > EXPECTED
@@ -514,15 +532,15 @@ cat <<EOF > 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 <<EOF > EXPECTED
@@ -530,6 +548,7 @@ cat <<EOF > 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 <<EOF > EXPECTED
@@ -546,16 +566,16 @@ cat <<EOF > 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 <<EOF > EXPECTED
@@ -563,15 +583,15 @@ cat <<EOF > 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 <<EOF > EXPECTED
@@ -579,15 +599,15 @@ cat <<EOF > 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 <<EOF > EXPECTED
@@ -595,15 +615,15 @@ cat <<EOF > 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 <<EOF > 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 <<EOF > 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 <<EOF > EXPECTED
@@ -674,6 +692,7 @@ cat <<EOF > 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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] test: sanitize line numbers in exception reports
2020-07-22 12:09 [PATCH 1/2] test: sanitize line numbers in exception reports David Bremner
2020-07-22 12:09 ` [PATCH 2/2] lib: fix exception messages for n_m_message_* David Bremner
@ 2020-07-23 10:11 ` David Bremner
1 sibling, 0 replies; 3+ messages in thread
From: David Bremner @ 2020-07-23 10:11 UTC (permalink / raw)
To: notmuch
David Bremner <david@tethera.net> writes:
> Prevent test suite churn when reported line numbers change.
> ---
> test/test-lib.sh | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
series applied to master
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-07-23 10:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-22 12:09 [PATCH 1/2] test: sanitize line numbers in exception reports David Bremner
2020-07-22 12:09 ` [PATCH 2/2] lib: fix exception messages for n_m_message_* David Bremner
2020-07-23 10:11 ` [PATCH 1/2] test: sanitize line numbers in exception reports David Bremner
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).