]> git.cworth.org Git - notmuch/commitdiff
test/emacs: add tests for hl-line-mode integration
authorDavid Bremner <david@tethera.net>
Sat, 10 Aug 2024 17:36:21 +0000 (14:36 -0300)
committerDavid Bremner <david@tethera.net>
Thu, 13 Mar 2025 10:18:07 +0000 (07:18 -0300)
Most of the known broken tests replicate (my intepretation of) the bug
reported at id:87fsfuuxwn.fsf@thinkbox (or some unreported, but
probably related bugs in tree/unthreaded view). The last 3 broken
tests are just unimplimented planned functionality.

test/T312-emacs-hl-line.sh [new file with mode: 0755]

diff --git a/test/T312-emacs-hl-line.sh b/test/T312-emacs-hl-line.sh
new file mode 100755 (executable)
index 0000000..4cceed3
--- /dev/null
@@ -0,0 +1,170 @@
+#!/usr/bin/env bash
+
+test_description="emacs hl-line-mode"
+. $(dirname "$0")/test-lib.sh || exit 1
+. $NOTMUCH_SRCDIR/test/test-lib-emacs.sh || exit 1
+
+EXPECTED=$NOTMUCH_SRCDIR/test/emacs.expected-output
+
+test_require_emacs
+add_email_corpus
+
+test_begin_subtest "line 1, search"
+test_emacs_expect_t '(let ((notmuch-hl-line t))
+                       (notmuch-search "tag:inbox")
+                       (notmuch-test-wait)
+                       (notmuch-test-expect-equal
+                        (let ((start (overlay-start hl-line-overlay))
+                              (end (overlay-end hl-line-overlay)))
+                          (list start (> end start)))
+                        (list 1 t)))'
+
+test_begin_subtest "line 1, tree"
+test_subtest_known_broken
+test_emacs_expect_t '(let ((notmuch-hl-line t))
+                       (notmuch-tree "tag:inbox")
+                       (notmuch-test-wait)
+                       (notmuch-test-expect-equal
+                        (let ((start (overlay-start hl-line-overlay))
+                              (end (overlay-end hl-line-overlay)))
+                          (list start (> end start)))
+                        (list 1 t)))'
+
+test_begin_subtest "line 1, unthreaded"
+test_subtest_known_broken
+test_emacs_expect_t '(let ((notmuch-hl-line t))
+                       (notmuch-tree "tag:inbox")
+                       (notmuch-test-wait)
+                       (notmuch-test-expect-equal
+                        (let ((start (overlay-start hl-line-overlay))
+                              (end (overlay-end hl-line-overlay)))
+                          (list start (> end start)))
+                        (list 1 t)))'
+
+test_begin_subtest "line 1, search, refresh"
+test_emacs_expect_t '(let ((notmuch-hl-line t))
+                       (notmuch-search "tag:inbox")
+                       (notmuch-test-wait)
+                       (notmuch-refresh-this-buffer)
+                       (notmuch-test-wait)
+                       (notmuch-test-expect-equal (overlay-start hl-line-overlay) 1))'
+
+test_begin_subtest "line 1, tree, refresh"
+test_subtest_known_broken
+test_emacs_expect_t '(let ((notmuch-hl-line t))
+                       (notmuch-tree "tag:inbox")
+                       (notmuch-test-wait)
+                       (notmuch-refresh-this-buffer)
+                       (notmuch-test-wait)
+                       (notmuch-test-expect-equal
+                        (let ((start (overlay-start hl-line-overlay))
+                              (end (overlay-end hl-line-overlay)))
+                          (list start (> end start)))
+                        (list 1 t)))'
+
+test_begin_subtest "line 1, unthreaded, refresh"
+test_subtest_known_broken
+test_emacs_expect_t '(let ((notmuch-hl-line t))
+                       (notmuch-tree "tag:inbox")
+                       (notmuch-test-wait)
+                       (notmuch-refresh-this-buffer)
+                       (notmuch-test-wait)
+                       (notmuch-test-expect-equal
+                        (let ((start (overlay-start hl-line-overlay))
+                              (end (overlay-end hl-line-overlay)))
+                          (list start (> end start)))
+                        (list 1 t)))'
+
+
+test_begin_subtest "line 12, notmuch-search"
+test_emacs_expect_t '(let ((notmuch-hl-line t))
+                       (notmuch-search "tag:inbox")
+                       (notmuch-test-wait)
+                       (forward-line 11)
+                       (notmuch-post-command)
+                       (notmuch-test-expect-equal
+                          (line-number-at-pos (overlay-start hl-line-overlay)) 12))'
+
+test_begin_subtest "line 12, tree"
+test_emacs_expect_t '(let ((notmuch-hl-line t))
+                       (notmuch-tree "tag:inbox")
+                       (notmuch-test-wait)
+                       (forward-line 11)
+                       (notmuch-post-command)
+                       (notmuch-test-expect-equal
+                          (line-number-at-pos (overlay-start hl-line-overlay)) 12))'
+
+test_begin_subtest "line 12, unthreaded"
+test_emacs_expect_t '(let ((notmuch-hl-line t))
+                       (notmuch-unthreaded "tag:inbox")
+                       (notmuch-test-wait)
+                       (forward-line 11)
+                       (notmuch-post-command)
+                       (notmuch-test-expect-equal
+                          (line-number-at-pos (overlay-start hl-line-overlay)) 12))'
+
+test_begin_subtest "line 12, search, refresh"
+test_subtest_known_broken
+test_emacs_expect_t '(let ((notmuch-hl-line t))
+                       (notmuch-search "tag:inbox")
+                       (notmuch-test-wait)
+                       (forward-line 11)
+                       (notmuch-post-command)
+                       (notmuch-refresh-this-buffer)
+                       (notmuch-test-wait)
+                       (notmuch-test-expect-equal
+                          (line-number-at-pos (overlay-start hl-line-overlay)) 12))'
+
+test_begin_subtest "line 12, tree, refresh"
+test_subtest_known_broken
+test_emacs_expect_t '(let ((notmuch-hl-line t))
+                       (notmuch-tree "tag:inbox")
+                       (notmuch-test-wait)
+                       (forward-line 11)
+                       (notmuch-post-command)
+                       (notmuch-refresh-this-buffer)
+                       (notmuch-test-wait)
+                       (notmuch-test-expect-equal
+                          (line-number-at-pos (overlay-start hl-line-overlay)) 12))'
+
+test_begin_subtest "line 12, unthreaded, refresh"
+test_subtest_known_broken
+test_emacs_expect_t '(let ((notmuch-hl-line t))
+                       (notmuch-tree "tag:inbox")
+                       (notmuch-test-wait)
+                       (forward-line 11)
+                       (notmuch-post-command)
+                       (notmuch-refresh-this-buffer)
+                       (notmuch-test-wait)
+                       (notmuch-test-expect-equal
+                          (line-number-at-pos (overlay-start hl-line-overlay)) 12))'
+
+test_begin_subtest "hl-line disabled, search"
+test_subtest_known_broken
+test_emacs_expect_t '(let ((notmuch-hl-line nil))
+                       (notmuch-search "tag:inbox")
+                       (notmuch-test-wait)
+                       (notmuch-test-expect-equal
+                          (or hl-line-mode hl-line-overlay)
+                          nil))'
+
+test_begin_subtest "hl-line disabled, tree"
+test_subtest_known_broken
+test_emacs_expect_t '(let ((notmuch-hl-line nil))
+                       (notmuch-tree "tag:inbox")
+                       (notmuch-test-wait)
+                       (notmuch-test-expect-equal
+                          (or hl-line-mode hl-line-overlay)
+                          nil))'
+
+test_begin_subtest "hl-line disabled, unthreaded"
+test_subtest_known_broken
+test_emacs_expect_t '(let ((notmuch-hl-line nil))
+                       (notmuch-unthreaded "tag:inbox")
+                       (notmuch-test-wait)
+                       (notmuch-test-expect-equal
+                          (or hl-line-mode hl-line-overlay)
+                          nil))'
+
+test_done
+