[PATCH 1/3] test: add known broken tests for notuch-{before,after}-tag-hook

Subject: [PATCH 1/3] test: add known broken tests for notuch-{before,after}-tag-hook

Date: Sat, 8 May 2021 09:11:11 -0300

To: notmuch@notmuchmail.org

Cc: jonas@bernoul.li, David Bremner

From: David Bremner


These tests illustrate the bug reported in id:87v97ytd2s.fsf@fastmail.fm
---
 test/T310-emacs.sh | 24 ++++++++++++++++++++++++
 test/test-lib.el   |  3 +++
 2 files changed, 27 insertions(+)

diff --git a/test/T310-emacs.sh b/test/T310-emacs.sh
index 78ac19a8..5ebc8e66 100755
--- a/test/T310-emacs.sh
+++ b/test/T310-emacs.sh
@@ -161,6 +161,30 @@ test_emacs "(notmuch-show \"$os_x_darwin_thread\")
 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
 test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox unread)"
 
+test_begin_subtest "notmuch-show: before-tag-hook is run, variables are defined"
+test_subtest_known_broken
+output=$(test_emacs '(let ((notmuch-test-tag-hook-output nil)
+	          (notmuch-before-tag-hook (function notmuch-test-tag-hook)))
+	       (notmuch-show "id:ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com")
+	       (execute-kbd-macro "+activate-hook\n")
+	       (execute-kbd-macro "-activate-hook\n")
+	       notmuch-test-tag-hook-output)')
+test_expect_equal "$output" \
+'(("id:ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com" "-activate-hook")
+ ("id:ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com" "+activate-hook"))'
+
+test_begin_subtest "notmuch-show: after-tag-hook is run, variables are defined"
+test_subtest_known_broken
+output=$(test_emacs '(let ((notmuch-test-tag-hook-output nil)
+	          (notmuch-after-tag-hook (function notmuch-test-tag-hook)))
+	       (notmuch-show "id:ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com")
+	       (execute-kbd-macro "+activate-hook\n")
+	       (execute-kbd-macro "-activate-hook\n")
+	       notmuch-test-tag-hook-output)')
+test_expect_equal "$output" \
+'(("id:ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com" "-activate-hook")
+ ("id:ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com" "+activate-hook"))'
+
 test_begin_subtest "Message with .. in Message-Id:"
 add_message [id]=123..456@example '[subject]="Message with .. in Message-Id"'
 test_emacs '(notmuch-search "id:\"123..456@example\"")
diff --git a/test/test-lib.el b/test/test-lib.el
index 4de5b292..32d53736 100644
--- a/test/test-lib.el
+++ b/test/test-lib.el
@@ -99,6 +99,9 @@ running, quit if it terminated."
 (add-hook 'notmuch-hello-refresh-hook
 	  (lambda () (cl-incf notmuch-hello-refresh-hook-counter)))
 
+(defvar notmuch-test-tag-hook-output nil)
+(defun notmuch-test-tag-hook () (push (cons query tag-changes) notmuch-test-tag-hook-output))
+
 (defun notmuch-test-mark-links ()
   "Enclose links in the current buffer with << and >>."
   ;; Links are often created by jit-lock functions
-- 
2.30.2
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: