]> git.eshelyaron.com Git - emacs.git/commitdiff
; Let files-tests.el pass multiple times in a session
authorNoam Postavsky <npostavs@gmail.com>
Thu, 31 Aug 2017 08:57:43 +0000 (04:57 -0400)
committerNoam Postavsky <npostavs@gmail.com>
Fri, 2 Feb 2018 23:09:13 +0000 (18:09 -0500)
* test/lisp/files-tests.el (files-test-local-variables): Use `cl-letf'
instead of advice.  The advice was not being activated on the second
run.

test/lisp/files-tests.el

index 8dbfc2965cacb6175f0620adbb64095a5f37b8aa..d51f8bb9f80652ae2ca8e5a3144420c71be8530c 100644 (file)
@@ -135,18 +135,16 @@ form.")
 
 (ert-deftest files-test-local-variables ()
   "Test the file-local variables implementation."
-  (unwind-protect
-      (progn
-       (defadvice hack-local-variables-confirm (around files-test activate)
-         (setq files-test-result 'query)
-         nil)
-       (dolist (test files-test-local-variable-data)
-         (let ((str (concat "text\n\n;; Local Variables:\n;; "
-                            (mapconcat 'identity (car test) "\n;; ")
-                            "\n;; End:\n")))
-           (dolist (subtest (cdr test))
-             (should (file-test--do-local-variables-test str subtest))))))
-    (ad-disable-advice 'hack-local-variables-confirm 'around 'files-test)))
+  (cl-letf (((symbol-function 'hack-local-variables-confirm)
+             (lambda (&rest _)
+               (setq files-test-result 'query)
+               nil)))
+    (dolist (test files-test-local-variable-data)
+      (let ((str (concat "text\n\n;; Local Variables:\n;; "
+                         (mapconcat 'identity (car test) "\n;; ")
+                         "\n;; End:\n")))
+        (dolist (subtest (cdr test))
+          (should (file-test--do-local-variables-test str subtest)))))))
 
 (defvar files-test-bug-18141-file
   (expand-file-name "data/files-bug18141.el.gz" (getenv "EMACS_TEST_DIRECTORY"))