unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Michael J Gruber <git@grubix.eu>
To: notmuch@notmuchmail.org
Subject: [PATCH] test: change database from within pre-new hook
Date: Tue, 11 May 2021 22:48:52 +0200	[thread overview]
Message-ID: <c12e24798d2f1f4c5a4e943043f1ab5107af22ac.1620766056.git.git@grubix.eu> (raw)
In-Reply-To: <162076424929.3234.3999254277296434834.git@grubix.eu>

Due to the change in the config system, notmuch keeps a notmuch database
open when it would not do so before. Consequently, it can miss changes
to the database which are done from a hook (while notmuch holds the
databse in read only mode). When notmuch itself writes to the database
after that it uses wrong assumptions about the last used doc id etc.

Demonstrate this by triggering an assertion. (This new test succeeds
with notmuch 0.31.4.)

Signed-off-by: Michael J Gruber <git@grubix.eu>
---
 test/T400-hooks.sh | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/test/T400-hooks.sh b/test/T400-hooks.sh
index 00c99337..58e2b1dd 100755
--- a/test/T400-hooks.sh
+++ b/test/T400-hooks.sh
@@ -28,6 +28,16 @@ EOF
     echo "${TOKEN}" > ${2}
 }
 
+create_change_hook () {
+    mkdir -p ${HOOK_DIR}
+    cat <<EOF >"${HOOK_DIR}/${1}"
+#!/bin/sh
+notmuch insert --no-hooks < ${2} > /dev/null
+rm -f ${2}
+EOF
+    chmod +x "${HOOK_DIR}/${1}"
+}
+
 create_failing_hook () {
     local HOOK_DIR=${2}
     mkdir -p ${HOOK_DIR}
@@ -176,6 +186,17 @@ EOF
     NOTMUCH_NEW
     test_expect_equal_file write.expected write.output
 
+    test_begin_subtest "pre-new with change in database [${config}]"
+    test_subtest_known_broken
+    rm -rf ${HOOK_DIR}
+    notmuch search '*' > change.expected
+    generate_message '[subject]="Inserted"'
+    create_change_hook "pre-new" $gen_msg_filename $HOOK_DIR
+    generate_message
+    NOTMUCH_NEW
+    output=$(notmuch search id:$gen_msg_id | notmuch_search_sanitize)
+    test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; pre-new with change in database [${config}] (inbox unread)"
+
     rm -rf ${HOOK_DIR}
 done
 test_done
-- 
2.31.1.708.gc9a0ac0934

  reply	other threads:[~2021-05-11 20:54 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-05  7:51 Possible threading issues in nm 0.32 Michael J Gruber
2021-05-05 12:29 ` David Bremner
2021-05-08 15:45   ` Michael J Gruber
2021-05-11 14:04     ` Alexander Adolf
2021-05-11 14:32       ` Alexander Adolf
2021-05-11 15:41         ` Michael J Gruber
2021-05-11 16:56           ` Michael J Gruber
2021-05-11 17:39             ` David Bremner
2021-05-11 17:42             ` [PATCH] lib/notmuch_database_reopen: reload some database metada David Bremner
2021-05-11 17:47               ` David Bremner
2021-05-11 20:17                 ` Michael J Gruber
2021-05-11 20:48                   ` Michael J Gruber [this message]
2021-05-11 22:34                     ` [PATCH] test: change database from within pre-new hook David Bremner
2021-05-12  7:23                       ` Michael J Gruber
2021-05-12 11:47                         ` David Bremner
2021-05-12 12:07                 ` [PATCH] lib/notmuch_database_reopen: reload some database metada David Bremner
2021-05-12 13:30                   ` Michael J Gruber
2021-05-16 11:11                     ` David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c12e24798d2f1f4c5a4e943043f1ab5107af22ac.1620766056.git.git@grubix.eu \
    --to=git@grubix.eu \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).