There 3 different tests here, repeated for oldest/newest first and
interactive / non-interactive. The "toggle twice" tests check that the
buffer local order is maintained between calls.
---
 test/T325-emacs-search-order.sh               | 129 ++++++++++++++++++
 .../notmuch-search-tag-inbox-oldest-first     |  25 ++++
 2 files changed, 154 insertions(+)
 create mode 100755 test/T325-emacs-search-order.sh
 create mode 100644 
test/emacs.expected-output/notmuch-search-tag-inbox-oldest-first

diff --git a/test/T325-emacs-search-order.sh b/test/T325-emacs-search-order.sh
new file mode 100755
index 00000000..87a5f137
--- /dev/null
+++ b/test/T325-emacs-search-order.sh
@@ -0,0 +1,129 @@
+#!/usr/bin/env bash
+
+test_description="emacs search order"
+. $(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 "Newest first"
+test_emacs '(notmuch-search "tag:inbox" nil)
+           (notmuch-test-wait)
+           (test-output)'
+test_expect_equal_file $EXPECTED/notmuch-search-tag-inbox OUTPUT
+
+test_begin_subtest "Oldest first"
+test_emacs '(notmuch-search "tag:inbox" t)
+           (notmuch-test-wait)
+           (test-output)'
+test_expect_equal_file $EXPECTED/notmuch-search-tag-inbox-oldest-first OUTPUT
+
+test_begin_subtest "Interactive, newest first"
+test_emacs "(cl-letf (((symbol-function 'notmuch-read-query) (lambda (_) 
\"tag:inbox\"))
+                      ((default-value 'notmuch-search-oldest-first) nil))
+               (call-interactively #'notmuch-search)
+               (notmuch-test-wait)
+               (test-output))"
+test_expect_equal_file $EXPECTED/notmuch-search-tag-inbox OUTPUT
+
+test_begin_subtest "Interactive, oldest first"
+test_emacs "(cl-letf (((symbol-function 'notmuch-read-query) (lambda (_) 
\"tag:inbox\"))
+                      ((default-value 'notmuch-search-oldest-first) t))
+               (call-interactively #'notmuch-search)
+               (notmuch-test-wait)
+               (test-output))"
+test_expect_equal_file $EXPECTED/notmuch-search-tag-inbox-oldest-first OUTPUT
+
+test_begin_subtest "Toggle order, initially newest first"
+test_emacs '(notmuch-search "tag:inbox" nil)
+            (notmuch-test-wait)
+           (goto-char (point-min))
+           (notmuch-search-toggle-order)
+           (notmuch-test-wait)
+           (test-output)'
+test_expect_equal_file $EXPECTED/notmuch-search-tag-inbox-oldest-first OUTPUT
+
+test_begin_subtest "Toggle order, initially oldest first"
+test_emacs '(notmuch-search "tag:inbox" t)
+            (notmuch-test-wait)
+           (goto-char (point-min))
+           (notmuch-search-toggle-order)
+           (notmuch-test-wait)
+           (test-output)'
+test_expect_equal_file $EXPECTED/notmuch-search-tag-inbox OUTPUT
+
+test_begin_subtest "Toggle order, interactive, initially newest first"
+test_emacs "(cl-letf (((symbol-function 'notmuch-read-query) (lambda (_) 
\"tag:inbox\"))
+                      ((default-value 'notmuch-search-oldest-first) nil))
+               (call-interactively #'notmuch-search)
+               (notmuch-test-wait)
+              (goto-char (point-min))
+              (notmuch-search-toggle-order)
+              (notmuch-test-wait)
+               (test-output))"
+test_expect_equal_file $EXPECTED/notmuch-search-tag-inbox-oldest-first OUTPUT
+
+test_begin_subtest "Toggle order, interactive, initially oldest first"
+test_emacs "(cl-letf (((symbol-function 'notmuch-read-query) (lambda (_) 
\"tag:inbox\"))
+                      ((default-value 'notmuch-search-oldest-first) t))
+               (call-interactively #'notmuch-search)
+               (notmuch-test-wait)
+              (goto-char (point-min))
+              (notmuch-search-toggle-order)
+              (notmuch-test-wait)
+               (test-output))"
+test_expect_equal_file $EXPECTED/notmuch-search-tag-inbox OUTPUT
+
+test_begin_subtest "Toggle order twice, initially newest first"
+test_emacs '(notmuch-search "tag:inbox" nil)
+            (notmuch-test-wait)
+           (goto-char (point-min))
+           (notmuch-search-toggle-order)
+           (notmuch-test-wait)
+           (notmuch-search-toggle-order)
+           (notmuch-test-wait)
+           (test-output)'
+test_expect_equal_file $EXPECTED/notmuch-search-tag-inbox OUTPUT
+
+test_begin_subtest "Toggle order twice, initially oldest first"
+test_emacs '(notmuch-search "tag:inbox" t)
+            (notmuch-test-wait)
+           (goto-char (point-min))
+           (notmuch-search-toggle-order)
+           (notmuch-test-wait)
+           (notmuch-search-toggle-order)
+           (notmuch-test-wait)
+           (test-output)'
+test_expect_equal_file $EXPECTED/notmuch-search-tag-inbox-oldest-first OUTPUT
+
+test_begin_subtest "Toggle order twice, interactive, initially newest first"
+test_emacs "(cl-letf (((symbol-function 'notmuch-read-query) (lambda (_) 
\"tag:inbox\"))
+                      ((default-value 'notmuch-search-oldest-first) nil))
+               (call-interactively #'notmuch-search)
+               (notmuch-test-wait)
+              (goto-char (point-min))
+              (notmuch-search-toggle-order)
+              (notmuch-test-wait)
+              (notmuch-search-toggle-order)
+              (notmuch-test-wait)
+               (test-output))"
+test_expect_equal_file $EXPECTED/notmuch-search-tag-inbox OUTPUT
+
+test_begin_subtest "Toggle order twice, interactive, initially oldest first"
+test_emacs "(cl-letf (((symbol-function 'notmuch-read-query) (lambda (_) 
\"tag:inbox\"))
+                      ((default-value 'notmuch-search-oldest-first) t))
+               (call-interactively #'notmuch-search)
+               (notmuch-test-wait)
+              (goto-char (point-min))
+              (notmuch-search-toggle-order)
+              (notmuch-test-wait)
+              (notmuch-search-toggle-order)
+              (notmuch-test-wait)
+               (test-output))"
+test_expect_equal_file $EXPECTED/notmuch-search-tag-inbox-oldest-first OUTPUT
+
+
+test_done
diff --git a/test/emacs.expected-output/notmuch-search-tag-inbox-oldest-first 
b/test/emacs.expected-output/notmuch-search-tag-inbox-oldest-first
new file mode 100644
index 00000000..1688d674
--- /dev/null
+++ b/test/emacs.expected-output/notmuch-search-tag-inbox-oldest-first
@@ -0,0 +1,25 @@
+  2009-11-17 [5/5]   Mikhail Gusarov, Carl Worth, Keith Packard  [notmuch] 
[PATCH 1/2] Close message file after parsing message headers (inbox unread)
+  2009-11-17 [7/7]   Lars Kellogg-Stedman, Mikhail Gusarov, Keith Packard, 
Carl Worth  [notmuch] Working with Maildir storage? (inbox signed unread)
+  2009-11-17 [2/2]   Alex Botero-Lowry, Carl Worth  [notmuch] preliminary 
FreeBSD support (attachment inbox unread)
+  2009-11-17 [1/1]   Mikhail Gusarov      [notmuch] [PATCH] Handle rename of 
message file (inbox unread)
+  2009-11-17 [2/2]   Keith Packard, Carl Worth    [notmuch] [PATCH] Make 
notmuch-show 'X' (and 'x') commands remove inbox (and unread) tags (inbox 
unread)
+  2009-11-17 [2/2]   Jan Janak, Carl Worth        [notmuch] [PATCH] Older 
versions of install do not support -C. (inbox unread)
+  2009-11-17 [3/3]   Jan Janak, Carl Worth        [notmuch] What a great idea! 
(inbox unread)
+  2009-11-17 [3/3]   Israel Herraiz, Keith Packard, Carl Worth   [notmuch] New 
to the list (inbox unread)
+  2009-11-17 [3/3]   Adrian Perez de Castro, Keith Packard, Carl Worth  
[notmuch] Introducing myself (inbox signed unread)
+  2009-11-17 [3/3]   Aron Griffis, Keith Packard, Carl Worth     [notmuch] 
archive (inbox unread)
+  2009-11-17 [2/2]   Ingmar Vanhassel, Carl Worth  [notmuch] [PATCH] Typsos 
(inbox unread)
+  2009-11-18 [2/2]   Alex Botero-Lowry, Carl Worth  [notmuch] [PATCH] Error 
out if no query is supplied to search instead of going into an infinite loop 
(attachment inbox unread)
+  2009-11-18 [2/2]   Lars Kellogg-Stedman [notmuch] "notmuch help" outputs to 
stderr? (attachment inbox signed unread)
+  2009-11-18 [1/1]   Stewart Smith        [notmuch] [PATCH] Fix linking with 
gcc to use g++ to link in C++ libs. (inbox unread)
+  2009-11-18 [1/1]   Stewart Smith        [notmuch] [PATCH 2/2] Read mail 
directory in inode number order (inbox unread)
+  2009-11-18 [1/1]   Stewart Smith        [notmuch] [PATCH] count_files: sort 
directory in inode order before statting (inbox unread)
+  2009-11-18 [4/4]   Jjgod Jiang, Alexander Botero-Lowry      [notmuch] Mac OS 
X/Darwin compatibility issues (inbox unread)
+  2009-11-18 [1/1]   Jan Janak            [notmuch] [PATCH] notmuch new: 
Support for conversion of spool subdirectories into tags (inbox unread)
+  2009-11-18 [1/1]   Rolland Santimano    [notmuch] Link to mailing list 
archives ? (inbox unread)
+  2009-11-18 [1/1]   Alexander Botero-Lowry  [notmuch] request for pull (inbox 
unread)
+  2009-11-18 [2/2]   Keith Packard, Alexander Botero-Lowry    [notmuch] 
[PATCH] Create a default notmuch-show-hook that highlights URLs and uses 
word-wrap (inbox unread)
+  2009-11-18 [1/1]   Chris Wilson         [notmuch] [PATCH 1/2] Makefile: 
evaluate pkg-config once (inbox unread)
+  2010-12-16 [1/1]   Olivier Berger       Essai accentué (inbox unread)
+  2010-12-29 [1/1]   François Boulogne    [aur-general] Guidelines: cp, mkdir 
vs install (inbox unread)
+End of search results.
-- 
2.51.0

_______________________________________________
notmuch mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to