[PATCH v3 32/34] emacs: Do not abuse advice to monkey patch while testing

Subject: [PATCH v3 32/34] emacs: Do not abuse advice to monkey patch while testing

Date: Sat, 8 Aug 2020 13:50:07 +0200

To: notmuch@notmuchmail.org

Cc:

From: Jonas Bernoulli


Use `cl-letf*' instead.
---
 test/T310-emacs.sh | 14 ++++++++------
 test/test-lib.el   |  8 --------
 2 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/test/T310-emacs.sh b/test/T310-emacs.sh
index 5f74305d..78ac19a8 100755
--- a/test/T310-emacs.sh
+++ b/test/T310-emacs.sh
@@ -40,12 +40,14 @@ test_emacs '(notmuch-search "tag:inbox")
 test_expect_equal_file $EXPECTED/notmuch-search-tag-inbox OUTPUT
 
 test_begin_subtest "Incremental parsing of search results"
-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_emacs "(cl-letf* (((symbol-function 'orig)
+			(symbol-function 'notmuch-search-process-filter))
+		       ((symbol-function 'notmuch-search-process-filter)
+			(lambda (proc string)
+			  (cl-loop for char across string
+				   do (orig proc (char-to-string char))))))
+	      (notmuch-search \"tag:inbox\")
+	      (notmuch-test-wait))
 	    (test-output)"
 test_expect_equal_file $EXPECTED/notmuch-search-tag-inbox OUTPUT
 
diff --git a/test/test-lib.el b/test/test-lib.el
index 044c2da4..ec16c59c 100644
--- a/test/test-lib.el
+++ b/test/test-lib.el
@@ -97,14 +97,6 @@ (defvar notmuch-hello-refresh-hook-counter -100
 (add-hook 'notmuch-hello-refresh-hook
 	  (lambda () (cl-incf notmuch-hello-refresh-hook-counter)))
 
-(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)))
-    (cl-loop for char across string
-	     do (progn
-		  (ad-set-arg 1 (char-to-string char))
-		  ad-do-it))))
-
 (defun notmuch-test-mark-links ()
   "Enclose links in the current buffer with << and >>."
   ;; Links are often created by jit-lock functions
-- 
2.28.0
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: