test: New test for incremental search output parsing
authorAustin Clements <amdragon@MIT.EDU>
Mon, 9 Jul 2012 21:42:39 +0000 (17:42 -0400)
committerDavid Bremner <bremner@debian.org>
Thu, 12 Jul 2012 23:39:18 +0000 (17:39 -0600)
This advises the search process filter to make it process one
character at a time in order to test the pessimal case for incremental
search output parsing.

The text parser fails this test because it gets tricked into thinking
a parenthetical remark in a subject is the tag list.

test/emacs
test/test-lib.el

index e9f954c37d5cfa985ed144e82c572c97cd027c56..293b12aa21bc545a073df2bc744afe3e4109282f 100755 (executable)
@@ -35,6 +35,17 @@ test_emacs '(notmuch-search "tag:inbox")
            (test-output)'
 test_expect_equal_file OUTPUT $EXPECTED/notmuch-search-tag-inbox
 
+test_begin_subtest "Incremental parsing of search results"
+test_subtest_known_broken
+test_emacs "(ad-enable-advice 'notmuch-search-process-filter 'around 'pessimal)
+           (ad-activate 'notmuch-search-process-filter)
+           (notmuch-search \"tag:inbox\")
+           (notmuch-test-wait)
+           (ad-disable-advice 'notmuch-search-process-filter 'around 'pessimal)
+           (ad-activate 'notmuch-search-process-filter)
+           (test-output)"
+test_expect_equal_file OUTPUT $EXPECTED/notmuch-search-tag-inbox
+
 test_begin_subtest "Navigation of notmuch-hello to search results"
 test_emacs '(notmuch-hello)
            (goto-char (point-min))
index 6271da22de4b97c2dbca1d37957a3b437af4833f..5dd6271c99dceb16417d947b87a731874d7c7c72 100644 (file)
@@ -89,6 +89,14 @@ nothing."
 (add-hook-counter 'notmuch-hello-mode-hook)
 (add-hook-counter 'notmuch-hello-refresh-hook)
 
+(defadvice notmuch-search-process-filter (around pessimal activate disable)
+  "Feed notmuch-search-process-filter one character at a time."
+  (let ((string (ad-get-arg 1)))
+    (loop for char across string
+         do (progn
+              (ad-set-arg 1 (char-to-string char))
+              ad-do-it))))
+
 (defmacro notmuch-test-run (&rest body)
   "Evaluate a BODY of test expressions and output the result."
   `(with-temp-buffer