From ced03a11efecce893b3c795bff7512d4e2b7abc9 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Mon, 5 Dec 2016 08:22:57 -0400 Subject: [PATCH 1/5] debian: disable gdb using tests on kfreebsd-* gdb seems broken there. --- debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/control b/debian/control index ba8642b4..e71a6716 100644 --- a/debian/control +++ b/debian/control @@ -22,7 +22,7 @@ Build-Depends: ruby, ruby-dev (>>1:1.9.3~), emacs24-nox | emacs24 (>=24~) | emacs24-lucid (>=24~) | emacs23-nox | emacs23 (>=23~) | emacs23-lucid (>=23~), - gdb [!s390x !ia64 !armel !ppc64el !mips !mipsel !mips64el], + gdb [!s390x !ia64 !armel !ppc64el !mips !mipsel !mips64el !kfreebsd-any], dtach (>= 0.8), gpgsm , gnupg , From 636367b4cf0bd8059a2238773dc40d55a2fb3472 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Mon, 5 Dec 2016 08:26:28 -0400 Subject: [PATCH 2/5] debian: changelog stanza for 0.23.3-3 --- debian/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/debian/changelog b/debian/changelog index 7c1a5303..9c2ebf75 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +notmuch (0.23.3-3) unstable; urgency=medium + + * Disable gdb using tests on kfreebsd-*, due to apparent gdb breakage + + -- David Bremner Mon, 05 Dec 2016 08:25:32 -0400 + notmuch (0.23.3-2) unstable; urgency=medium * Add missing depends to notmuch-emacs. Thanks to micah for the From 27e293f653b2688fc4452a92c99e76c7e97669d1 Mon Sep 17 00:00:00 2001 From: Tomi Ollila Date: Mon, 28 Nov 2016 23:07:08 +0200 Subject: [PATCH 3/5] test: gdb insert: redirect input inside gdb script Running `gdb command < input` is not as reliable way to give input to the command (some installations of gdb consume it). Use "set args" gdb command to have input redirected at gdb 'run' time. --- test/T070-insert.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/T070-insert.sh b/test/T070-insert.sh index c2485bb2..43b3abcf 100755 --- a/test/T070-insert.sh +++ b/test/T070-insert.sh @@ -202,13 +202,15 @@ end run EOF test_begin_subtest "error exit when add_message returns $code" -gdb --batch-silent --return-child-result -x index-file-$code.gdb \ - --args notmuch insert < $gen_msg_filename +gdb --batch-silent --return-child-result \ + -ex "set args insert < $gen_msg_filename" \ + -x index-file-$code.gdb notmuch test_expect_equal $? 1 test_begin_subtest "success exit with --keep when add_message returns $code" -gdb --batch-silent --return-child-result -x index-file-$code.gdb \ - --args notmuch insert --keep < $gen_msg_filename +gdb --batch-silent --return-child-result \ + -ex "set args insert --keep < $gen_msg_filename" \ + -x index-file-$code.gdb notmuch test_expect_equal $? 0 done From 9259b97fa2659ae6b6dbcd49b04db087e64036ad Mon Sep 17 00:00:00 2001 From: David Bremner Date: Sun, 27 Nov 2016 11:24:58 -0400 Subject: [PATCH 4/5] cli/insert: delay database open until after writing mail file The idea is to get the mail written to disk, even if we can't open the database (e.g. because some other process has a write lock, and notmuch is compiled for non-blocking opens). --- notmuch-insert.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/notmuch-insert.c b/notmuch-insert.c index 131f09e2..862da889 100644 --- a/notmuch-insert.c +++ b/notmuch-insert.c @@ -532,18 +532,18 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[]) action.sa_flags = 0; sigaction (SIGINT, &action, NULL); - if (notmuch_database_open (notmuch_config_get_database_path (config), + /* Write the message to the Maildir new directory. */ + newpath = maildir_write_new (config, STDIN_FILENO, maildir); + if (! newpath) { + return EXIT_FAILURE; + } + + if (notmuch_database_open (notmuch_config_get_database_path (config), NOTMUCH_DATABASE_MODE_READ_WRITE, ¬much)) return EXIT_FAILURE; notmuch_exit_if_unmatched_db_uuid (notmuch); - /* Write the message to the Maildir new directory. */ - newpath = maildir_write_new (config, STDIN_FILENO, maildir); - if (! newpath) { - notmuch_database_destroy (notmuch); - return EXIT_FAILURE; - } /* Index the message. */ status = add_file (notmuch, newpath, tag_ops, synchronize_flags, keep); From d74c5345704136611f993ca38e0d035b1da798b6 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Sun, 27 Nov 2016 23:01:42 -0400 Subject: [PATCH 5/5] cli/insert: return EX_TEMPFAIL for some errors Attempt to distinguish between errors indicating misconfiguration or programmer error, which we consider "permanent", in the sense that automatic retries are unlikely to be useful, and those indicating transient error conditions. We consider XAPIAN_EXCEPTION transient because it covers the important special case of locking failure. --- notmuch-client.h | 3 +++ notmuch-insert.c | 9 +++++---- status.c | 16 ++++++++++++++++ test/T070-insert.sh | 34 +++++++++++++++++++++++----------- 4 files changed, 47 insertions(+), 15 deletions(-) diff --git a/notmuch-client.h b/notmuch-client.h index 793f32ec..d026e600 100644 --- a/notmuch-client.h +++ b/notmuch-client.h @@ -489,6 +489,9 @@ print_status_database (const char *loc, const notmuch_database_t *database, notmuch_status_t status); +int +status_to_exit (notmuch_status_t status); + #include "command-line-arguments.h" extern char *notmuch_requested_db_uuid; diff --git a/notmuch-insert.c b/notmuch-insert.c index 862da889..bc96af0e 100644 --- a/notmuch-insert.c +++ b/notmuch-insert.c @@ -538,9 +538,10 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[]) return EXIT_FAILURE; } - if (notmuch_database_open (notmuch_config_get_database_path (config), - NOTMUCH_DATABASE_MODE_READ_WRITE, ¬much)) - return EXIT_FAILURE; + status = notmuch_database_open (notmuch_config_get_database_path (config), + NOTMUCH_DATABASE_MODE_READ_WRITE, ¬much); + if (status) + return keep ? NOTMUCH_STATUS_SUCCESS : status_to_exit (status); notmuch_exit_if_unmatched_db_uuid (notmuch); @@ -577,5 +578,5 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[]) notmuch_run_hook (db_path, "post-insert"); } - return status ? EXIT_FAILURE : EXIT_SUCCESS; + return status_to_exit (status); } diff --git a/status.c b/status.c index 45d3fb4e..8bc2fe4b 100644 --- a/status.c +++ b/status.c @@ -36,3 +36,19 @@ print_status_database (const char *loc, } return status; } + +int +status_to_exit (notmuch_status_t status) +{ + switch (status) { + case NOTMUCH_STATUS_SUCCESS: + return EXIT_SUCCESS; + case NOTMUCH_STATUS_OUT_OF_MEMORY: + case NOTMUCH_STATUS_XAPIAN_EXCEPTION: + case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID: + case NOTMUCH_STATUS_FILE_ERROR: + return EX_TEMPFAIL; + default: + return EXIT_FAILURE; + } +} diff --git a/test/T070-insert.sh b/test/T070-insert.sh index 43b3abcf..57472b91 100755 --- a/test/T070-insert.sh +++ b/test/T070-insert.sh @@ -189,7 +189,6 @@ notmuch config set new.tags $OLDCONFIG for code in OUT_OF_MEMORY XAPIAN_EXCEPTION FILE_NOT_EMAIL \ READ_ONLY_DATABASE UPGRADE_REQUIRED PATH_ERROR; do -gen_insert_msg cat < index-file-$code.gdb set breakpoint pending on set logging file index-file-$code.log @@ -201,17 +200,30 @@ continue end run EOF -test_begin_subtest "error exit when add_message returns $code" -gdb --batch-silent --return-child-result \ - -ex "set args insert < $gen_msg_filename" \ - -x index-file-$code.gdb notmuch -test_expect_equal $? 1 +done -test_begin_subtest "success exit with --keep when add_message returns $code" -gdb --batch-silent --return-child-result \ - -ex "set args insert --keep < $gen_msg_filename" \ - -x index-file-$code.gdb notmuch -test_expect_equal $? 0 +gen_insert_msg + +for code in FILE_NOT_EMAIL READ_ONLY_DATABASE UPGRADE_REQUIRED PATH_ERROR; do + test_expect_code 1 "EXIT_FAILURE when add_message returns $code" \ + "gdb --batch-silent --return-child-result \ + -ex 'set args insert < $gen_msg_filename' \ + -x index-file-$code.gdb notmuch" + test_expect_code 0 "success exit with --keep when add_message returns $code" \ + "gdb --batch-silent --return-child-result \ + -ex 'set args insert --keep < $gen_msg_filename' \ + -x index-file-$code.gdb notmuch" +done + +for code in OUT_OF_MEMORY XAPIAN_EXCEPTION ; do + test_expect_code 75 "EX_TEMPFAIL when add_message returns $code" \ + "gdb --batch-silent --return-child-result \ + -ex 'set args insert < $gen_msg_filename' \ + -x index-file-$code.gdb notmuch" + test_expect_code 0 "success exit with --keep when add_message returns $code" \ + "gdb --batch-silent --return-child-result \ + -ex 'set args insert --keep < $gen_msg_filename' \ + -x index-file-$code.gdb notmuch" done test_done