]> git.eshelyaron.com Git - emacs.git/commitdiff
Move buffer related functions from ert-x.el to ert.el
authorStefan Kangas <stefankangas@gmail.com>
Mon, 24 Feb 2025 19:25:01 +0000 (20:25 +0100)
committerEshel Yaron <me@eshelyaron.com>
Wed, 26 Feb 2025 09:35:54 +0000 (10:35 +0100)
* lisp/emacs-lisp/ert-x.el (ert--text-button)
(ert--format-test-buffer-name, ert--test-buffers)
(ert--test-buffer-button, ert--test-buffer-button-action)
(ert--call-with-test-buffer, ert-with-test-buffer)
(ert-with-buffer-selected, ert-kill-all-test-buffers)
(ert-call-with-buffer-renamed, ert-buffer-string-reindented): Move
from here...
* lisp/emacs-lisp/ert.el (ert--text-button)
(ert--format-test-buffer-name, ert--test-buffers)
(ert--test-buffer-button, ert--test-buffer-button-action)
(ert--call-with-test-buffer, ert-with-test-buffer)
(ert-kill-all-test-buffers, ert-with-buffer-selected)
(ert-call-with-buffer-renamed, ert-with-buffer-renamed): ...to
here.
* doc/misc/ert.texi (Helpers for Buffers): Break out new section...
(Helper Functions): ...from here.
* lisp/emacs-lisp/ert-x.el (ert-with-test-buffer-selected): Move
obsolete definition to the end of the file.

* test/lisp/emacs-lisp/ert-x-tests.el
(ert--hash-table-to-alist, ert-test-test-buffers)
(ert-test-with-buffer-selected/current)
(ert-test-with-buffer-selected/selected)
(ert-test-with-buffer-selected/nil-buffer)
(ert-test-with-buffer-selected/modification-hooks)
(ert-test-with-buffer-selected/read-only)
(ert-test-with-buffer-selected/return-value)
(ert-test-with-test-buffer-selected/modification-hooks)
(ert-test-with-test-buffer-selected/read-only)
(ert-test-with-test-buffer-selected/return-value)
(ert-test-with-test-buffer-selected/buffer-name): Move tests from
here...
* test/lisp/emacs-lisp/ert-tests.el
(ert--hash-table-to-alist, ert-test-test-buffers)
(ert-test-with-buffer-selected/current)
(ert-test-with-buffer-selected/selected)
(ert-test-with-buffer-selected/nil-buffer)
(ert-test-with-buffer-selected/modification-hooks)
(ert-test-with-buffer-selected/read-only)
(ert-test-with-buffer-selected/return-value)
(ert-test-with-test-buffer-selected/selected)
(ert-test-with-test-buffer-selected/modification-hooks)
(ert-test-with-test-buffer-selected/read-only)
(ert-test-with-test-buffer-selected/return-value)
(ert-test-with-test-buffer-selected/buffer-name): ...to here.
* test/lisp/progmodes/hideshow-tests.el (ert-x):
* test/lisp/simple-tests.el (ert-x):
* test/lisp/whitespace-tests.el (ert-x): Don't require.

(cherry picked from commit c9e681aa0c75feaf1c0a5495b0d475698cbdb653)

doc/misc/ert.texi
lisp/emacs-lisp/ert-x.el
lisp/emacs-lisp/ert.el
test/lisp/emacs-lisp/ert-tests.el
test/lisp/emacs-lisp/ert-x-tests.el
test/lisp/progmodes/hideshow-tests.el
test/lisp/simple-tests.el
test/lisp/whitespace-tests.el

index 19726d3ca2f9ae891459a8dbd6b4055e9c26cdb5..ca74b6cabb8ddeccc544dde7c2cea27dbd8828e4 100644 (file)
@@ -530,6 +530,7 @@ to find where a test was defined if the test was loaded from a file.
 * Useful Techniques::           Some examples.
 * erts files::                  Files containing many buffer tests.
 * Syntax Highlighting Tests::   Tests for face assignment.
+* Helpers for Buffers::         Dealing with buffers during tests.
 * Helper Functions::            Various helper functions.
 @end menu
 
@@ -1080,13 +1081,20 @@ macros accept the same keyword parameters as @code{ert-deftest} i.e.,
 @code{:tag} and @code{:expected-result}.
 
 
-@node Helper Functions
-@section Various Helper Functions
+@node Helpers for Buffers
+@section Handling Buffers during tests
 
-The package @file{ert-x.el} contains some macros and functions useful
-for writing tests.
+ERT comes with some macros for dealing with buffers used when testing.
 
-@subsection Test Buffers
+@subsection Creating temporary buffers
+
+@findex ert-kill-all-test-buffers
+The @code{ert-with-test-buffer} macro can be used to create a temporary
+buffer during a test, which is cleaned up automatically if the test is
+successful.  But if the test fails, the buffer stays around so that you
+can more easily investigate the test failure.  When you are done, you
+can use the command @code{ert-kill-all-test-buffers} to kill all test
+buffers that have been created by this macro.
 
 @defmac ert-with-test-buffer ((&key ((:name name-form :selected select-form))) &body body)
 This macro creates a test buffer and runs @var{body} in that buffer.  If
@@ -1139,9 +1147,7 @@ value is the last form in @var{body}.  Example:
 This displays a temporary buffer like @file{ *temp*-739785*}.
 @end defmac
 
-@defun ert-kill-all-test-buffers ()
-It kills all test buffers that are still live.
-@end defun
+@subsection Protecting buffers
 
 @defmac ert-with-buffer-renamed ((buffer-name-form) &body body)
 This macro protects the buffer @var{buffer-name} from side-effects and
@@ -1158,6 +1164,13 @@ buffer with a fixed name such as @file{*Messages*}.  Example:
 @end lisp
 @end defmac
 
+
+@node Helper Functions
+@section Various Helper Functions
+
+The package @file{ert-x.el} contains some macros and functions useful
+for writing tests.
+
 @defmac ert-with-message-capture (var &rest body)
 This macro executes @var{body} while collecting messages in @var{var}.
 It captures messages issued by Lisp code and concatenates them separated
index 0c87653ca7a7b985e75083204a6bb8f3e89d4f57..042c329a37a332239fef2e87003c7651ccb2de46 100644 (file)
 (require 'ert)
 (require 'subr-x)
 
-
-;;; Test buffers.
-
-(defun ert--text-button (string &rest properties)
-  "Return a string containing STRING as a text button with PROPERTIES.
-
-See `make-text-button'."
-  (with-temp-buffer
-    (insert string)
-    (apply #'make-text-button (point-min) (point-max) properties)
-    (buffer-string)))
-
-(defun ert--format-test-buffer-name (base-name)
-  "Compute a test buffer name based on BASE-NAME.
-
-Helper function for `ert--test-buffers'."
-  (format "*Test buffer (%s)%s*"
-         (or (and (ert-running-test)
-                  (ert-test-name (ert-running-test)))
-             "<anonymous test>")
-         (if base-name
-             (format ": %s" base-name)
-           "")))
-
-(defvar ert--test-buffers (make-hash-table :weakness t)
-  "Table of all test buffers.  Keys are the buffer objects, values are t.
-
-The main use of this table is for `ert-kill-all-test-buffers'.
-Not all buffers in this table are necessarily live, but all live
-test buffers are in this table.")
-
-(define-button-type 'ert--test-buffer-button
-  'action #'ert--test-buffer-button-action
-  'help-echo "mouse-2, RET: Pop to test buffer")
-
-(defun ert--test-buffer-button-action (button)
-  "Pop to the test buffer that BUTTON is associated with."
-  (pop-to-buffer (button-get button 'ert--test-buffer)))
-
-(defun ert--call-with-test-buffer (ert--base-name ert--thunk)
-  "Helper function for `ert-with-test-buffer'.
-
-Create a test buffer with a name based on ERT--BASE-NAME and run
-ERT--THUNK with that buffer as current."
-  (let* ((ert--buffer (generate-new-buffer
-                       (ert--format-test-buffer-name ert--base-name)))
-         (ert--button (ert--text-button (buffer-name ert--buffer)
-                                        :type 'ert--test-buffer-button
-                                        'ert--test-buffer ert--buffer)))
-    (puthash ert--buffer 't ert--test-buffers)
-    ;; We don't use `unwind-protect' here since we want to kill the
-    ;; buffer only on success.
-    (prog1 (with-current-buffer ert--buffer
-             (ert-info (ert--button :prefix "Buffer: ")
-               (funcall ert--thunk)))
-      (kill-buffer ert--buffer)
-      (remhash ert--buffer ert--test-buffers))))
-
-(cl-defmacro ert-with-test-buffer ((&key ((:name name-form))
-                                         ((:selected select-form)))
-                                   &body body)
-  "Create a test buffer and run BODY in that buffer.
-
-To be used in ERT tests.  If BODY finishes successfully, the test buffer
-is killed; if there is an error, the test buffer is kept around for
-further inspection.  The name of the buffer is derived from the name of
-the test and the result of NAME-FORM.
-
-If SELECT-FORM is non-nil, switch to the test buffer before running
-BODY, as if body was in `ert-with-buffer-selected'.
-
-The return value is the last form in BODY."
-  (declare (debug ((":name" form) (":selected" form) def-body))
-           (indent 1))
-  `(ert--call-with-test-buffer
-    ,name-form
-    ,(if select-form
-         `(lambda () (ert-with-buffer-selected (current-buffer)
-                  ,@body))
-       `(lambda () ,@body))))
-
-(cl-defmacro ert-with-buffer-selected (buffer-or-name &body body)
-  "Display a buffer in a temporary selected window and run BODY.
-
-If BUFFER-OR-NAME is nil, the current buffer is used.
-
-The buffer is made the current buffer, and the temporary window
-becomes the `selected-window', before BODY is evaluated.  The
-modification hooks `before-change-functions' and
-`after-change-functions' are not inhibited during the evaluation
-of BODY, which makes it easier to use `execute-kbd-macro' to
-simulate user interaction.  The window configuration is restored
-before returning, even if BODY exits nonlocally.  The return
-value is the last form in BODY."
-  (declare (debug (form body)) (indent 1))
-  `(save-window-excursion
-     (with-current-buffer (or ,buffer-or-name (current-buffer))
-       (with-selected-window (display-buffer (current-buffer))
-         ,@body))))
-
-(cl-defmacro ert-with-test-buffer-selected ((&key name) &body body)
-  "Create a test buffer, switch to it, and run BODY.
-
-This combines `ert-with-test-buffer' and `ert-with-buffer-selected'.
-The return value is the last form in BODY."
-  (declare (obsolete ert-with-test-buffer "31.1")
-           (debug ((":name" form) body)) (indent 1))
-  `(ert-with-test-buffer (:name ,name :selected t)
-     ,@body))
-
-;;;###autoload
-(defun ert-kill-all-test-buffers ()
-  "Kill all test buffers that are still live."
-  (interactive)
-  (let ((count 0))
-    (maphash (lambda (buffer _dummy)
-              (when (or (not (buffer-live-p buffer))
-                        (kill-buffer buffer))
-                 (incf count)))
-            ert--test-buffers)
-    (message "%s out of %s test buffers killed"
-            count (hash-table-count ert--test-buffers)))
-  ;; It could be that some test buffers were actually kept alive
-  ;; (e.g., due to `kill-buffer-query-functions').  I'm not sure what
-  ;; to do about this.  For now, let's just forget them.
-  (clrhash ert--test-buffers)
-  nil)
-
-
 ;;; Simulate commands.
 
 (defun ert-simulate-command (command)
@@ -275,37 +146,6 @@ structure with the plists in ARGS."
                      (setq current-plist x))))
     (buffer-string)))
 
-
-(defun ert-call-with-buffer-renamed (buffer-name thunk)
-  "Protect the buffer named BUFFER-NAME from side-effects and run THUNK.
-
-Renames the buffer BUFFER-NAME to a new temporary name, creates a
-new buffer named BUFFER-NAME, executes THUNK, kills the new
-buffer, and renames the original buffer back to BUFFER-NAME.
-
-This is useful if THUNK has undesirable side-effects on an Emacs
-buffer with a fixed name such as *Messages*."
-  (let ((new-buffer-name (generate-new-buffer-name
-                          (format "%s orig buffer" buffer-name))))
-    (with-current-buffer (get-buffer-create buffer-name)
-      (rename-buffer new-buffer-name))
-    (unwind-protect
-        (progn
-          (get-buffer-create buffer-name)
-          (funcall thunk))
-      (when (get-buffer buffer-name)
-        (kill-buffer buffer-name))
-      (with-current-buffer new-buffer-name
-        (rename-buffer buffer-name)))))
-
-(cl-defmacro ert-with-buffer-renamed ((buffer-name-form) &body body)
-  "Protect the buffer named BUFFER-NAME from side-effects and run BODY.
-
-See `ert-call-with-buffer-renamed' for details."
-  (declare (indent 1))
-  `(ert-call-with-buffer-renamed ,buffer-name-form (lambda () ,@body)))
-
-
 (defun ert-buffer-string-reindented (&optional buffer)
   "Return the contents of BUFFER after reindentation.
 
@@ -571,6 +411,19 @@ The same keyword arguments are supported as in
         (format "/mock::%s" temporary-file-directory))))
   "Temporary directory for remote file tests.")
 
+\f
+;;;; Obsolete
+
+(cl-defmacro ert-with-test-buffer-selected ((&key name) &body body)
+  "Create a test buffer, switch to it, and run BODY.
+
+This combines `ert-with-test-buffer' and `ert-with-buffer-selected'.
+The return value is the last form in BODY."
+  (declare (obsolete ert-with-test-buffer "31.1")
+           (debug ((":name" form) body)) (indent 1))
+  `(ert-with-test-buffer (:name ,name :selected t)
+     ,@body))
+
 (provide 'ert-x)
 
 ;;; ert-x.el ends here
index 5825807595a393fffac52834a4576272cb8df497..e2bb2703ac3c86c02edbf10bedfecf6b8a911aad 100644 (file)
@@ -2981,6 +2981,152 @@ write erts files."
           (forward-line 1)))
       (nreverse specs))))
 
+\f
+;;; Buffer related helpers
+
+(defun ert--text-button (string &rest properties)
+  "Return a string containing STRING as a text button with PROPERTIES.
+
+See `make-text-button'."
+  (with-temp-buffer
+    (insert string)
+    (apply #'make-text-button (point-min) (point-max) properties)
+    (buffer-string)))
+
+(defun ert--format-test-buffer-name (base-name)
+  "Compute a test buffer name based on BASE-NAME.
+
+Helper function for `ert--test-buffers'."
+  (format "*Test buffer (%s)%s*"
+          (or (and (ert-running-test)
+                   (ert-test-name (ert-running-test)))
+              "<anonymous test>")
+          (if base-name
+              (format ": %s" base-name)
+            "")))
+
+(defvar ert--test-buffers (make-hash-table :weakness t)
+  "Table of all test buffers.  Keys are the buffer objects, values are t.
+
+The main use of this table is for `ert-kill-all-test-buffers'.
+Not all buffers in this table are necessarily live, but all live
+test buffers are in this table.")
+
+(define-button-type 'ert--test-buffer-button
+  'action #'ert--test-buffer-button-action
+  'help-echo "mouse-2, RET: Pop to test buffer")
+
+(defun ert--test-buffer-button-action (button)
+  "Pop to the test buffer that BUTTON is associated with."
+  (pop-to-buffer (button-get button 'ert--test-buffer)))
+
+(defun ert--call-with-test-buffer (ert--base-name ert--thunk)
+  "Helper function for `ert-with-test-buffer'.
+
+Create a test buffer with a name based on ERT--BASE-NAME and run
+ERT--THUNK with that buffer as current."
+  (let* ((ert--buffer (generate-new-buffer
+                    (ert--format-test-buffer-name ert--base-name)))
+         (ert--button (ert--text-button (buffer-name ert--buffer)
+                                  :type 'ert--test-buffer-button
+                                  'ert--test-buffer ert--buffer)))
+    (puthash ert--buffer 't ert--test-buffers)
+    ;; We don't use `unwind-protect' here since we want to kill the
+    ;; buffer only on success.
+    (prog1 (with-current-buffer ert--buffer
+             (ert-info (ert--button :prefix "Buffer: ")
+               (funcall ert--thunk)))
+      (kill-buffer ert--buffer)
+      (remhash ert--buffer ert--test-buffers))))
+
+(cl-defmacro ert-with-test-buffer ((&key ((:name name-form))
+                                      ((:selected select-form)))
+                                &body body)
+  "Create a test buffer and run BODY in that buffer.
+
+To be used in ERT tests.  If BODY finishes successfully, the test buffer
+is killed; if there is an error, the test buffer is kept around for
+further inspection.  The name of the buffer is derived from the name of
+the test and the result of NAME-FORM.
+
+If SELECT-FORM is non-nil, switch to the test buffer before running
+BODY, as if body was in `ert-with-buffer-selected'.
+
+The return value is the last form in BODY."
+  (declare (debug ((":name" form) (":selected" form) def-body))
+           (indent 1))
+  `(ert--call-with-test-buffer
+    ,name-form
+    ,(if select-form
+         `(lambda () (ert-with-buffer-selected (current-buffer)
+                  ,@body))
+       `(lambda () ,@body))))
+
+(defun ert-kill-all-test-buffers ()
+  "Kill all test buffers that are still live."
+  (interactive)
+  (let ((count 0))
+    (maphash (lambda (buffer _dummy)
+               (when (or (not (buffer-live-p buffer))
+                         (kill-buffer buffer))
+                 (incf count)))
+             ert--test-buffers)
+    (message "%s out of %s test buffers killed"
+             count (hash-table-count ert--test-buffers)))
+  ;; It could be that some test buffers were actually kept alive
+  ;; (e.g., due to `kill-buffer-query-functions').  I'm not sure what
+  ;; to do about this.  For now, let's just forget them.
+  (clrhash ert--test-buffers)
+  nil)
+
+(cl-defmacro ert-with-buffer-selected (buffer-or-name &body body)
+  "Display a buffer in a temporary selected window and run BODY.
+
+If BUFFER-OR-NAME is nil, the current buffer is used.
+
+The buffer is made the current buffer, and the temporary window
+becomes the `selected-window', before BODY is evaluated.  The
+modification hooks `before-change-functions' and
+`after-change-functions' are not inhibited during the evaluation
+of BODY, which makes it easier to use `execute-kbd-macro' to
+simulate user interaction.  The window configuration is restored
+before returning, even if BODY exits nonlocally.  The return
+value is the last form in BODY."
+  (declare (debug (form body)) (indent 1))
+  `(save-window-excursion
+     (with-current-buffer (or ,buffer-or-name (current-buffer))
+       (with-selected-window (display-buffer (current-buffer))
+         ,@body))))
+
+(defun ert-call-with-buffer-renamed (buffer-name thunk)
+  "Protect the buffer named BUFFER-NAME from side-effects and run THUNK.
+
+Renames the buffer BUFFER-NAME to a new temporary name, creates a
+new buffer named BUFFER-NAME, executes THUNK, kills the new
+buffer, and renames the original buffer back to BUFFER-NAME.
+
+This is useful if THUNK has undesirable side-effects on an Emacs
+buffer with a fixed name such as *Messages*."
+  (let ((new-buffer-name (generate-new-buffer-name
+                          (format "%s orig buffer" buffer-name))))
+    (with-current-buffer (get-buffer-create buffer-name)
+      (rename-buffer new-buffer-name))
+    (unwind-protect
+        (progn
+          (get-buffer-create buffer-name)
+          (funcall thunk))
+      (when (get-buffer buffer-name)
+        (kill-buffer buffer-name))
+      (with-current-buffer new-buffer-name
+        (rename-buffer buffer-name)))))
+
+(cl-defmacro ert-with-buffer-renamed ((buffer-name-form) &body body)
+  "Protect the buffer named BUFFER-NAME from side-effects and run BODY.
+
+See `ert-call-with-buffer-renamed' for details."
+  (declare (indent 1))
+  `(ert-call-with-buffer-renamed ,buffer-name-form (lambda () ,@body)))
+
 ;;; Obsolete
 
 (define-obsolete-function-alias 'ert-equal-including-properties
index d60d9479c2b5bd1a64b1ce0b81a61a6a95f86520..75b40d0db11f48b2aa06d236eeae1bea18ba497c 100644 (file)
@@ -930,6 +930,97 @@ F failing-test
           (when noninteractive
             (kill-buffer buffer-name)))))))
 
+(defun ert--hash-table-to-alist (table)
+  (let ((accu nil))
+    (maphash (lambda (key value)
+               (push (cons key value) accu))
+             table)
+    (nreverse accu)))
+
+(ert-deftest ert-test-test-buffers ()
+  (let (buffer-1
+        buffer-2)
+    (let ((test-1
+           (make-ert-test
+            :name 'test-1
+            :body (lambda ()
+                    (ert-with-test-buffer (:name "foo")
+                      (should (string-match
+                               "[*]Test buffer (ert-test-test-buffers): foo[*]"
+                               (buffer-name)))
+                      (setq buffer-1 (current-buffer))))))
+          (test-2
+           (make-ert-test
+            :name 'test-2
+            :body (lambda ()
+                    (ert-with-test-buffer (:name "bar")
+                      (should (string-match
+                               "[*]Test buffer (ert-test-test-buffers): bar[*]"
+                               (buffer-name)))
+                      (setq buffer-2 (current-buffer))
+                      (ert-fail "fail for test"))))))
+      (let ((ert--test-buffers (make-hash-table :weakness t)))
+        (ert-run-tests `(member ,test-1 ,test-2) #'ignore)
+        (should (equal (ert--hash-table-to-alist ert--test-buffers)
+                       `((,buffer-2 . t))))
+        (should-not (buffer-live-p buffer-1))
+        (should (buffer-live-p buffer-2))))))
+
+(ert-deftest ert-test-with-buffer-selected/current ()
+  (let ((origbuf (current-buffer)))
+    (ert-with-test-buffer ()
+      (let ((buf (current-buffer)))
+        (should (not (eq buf origbuf)))
+        (with-current-buffer origbuf
+          (ert-with-buffer-selected buf
+            (should (eq (current-buffer) buf))))))))
+
+(ert-deftest ert-test-with-buffer-selected/selected ()
+  (ert-with-test-buffer ()
+    (ert-with-buffer-selected (current-buffer)
+      (should (eq (window-buffer) (current-buffer))))))
+
+(ert-deftest ert-test-with-buffer-selected/nil-buffer ()
+  (ert-with-test-buffer ()
+    (let ((buf (current-buffer)))
+      (ert-with-buffer-selected nil
+        (should (eq (window-buffer) buf))))))
+
+(ert-deftest ert-test-with-buffer-selected/modification-hooks ()
+  (ert-with-test-buffer ()
+    (ert-with-buffer-selected (current-buffer)
+      (should (null inhibit-modification-hooks)))))
+
+(ert-deftest ert-test-with-buffer-selected/read-only ()
+  (ert-with-test-buffer ()
+    (ert-with-buffer-selected (current-buffer)
+      (should (null inhibit-read-only))
+      (should (null buffer-read-only)))))
+
+(ert-deftest ert-test-with-buffer-selected/return-value ()
+  (should (equal (ert-with-buffer-selected nil "foo") "foo")))
+
+(ert-deftest ert-test-with-test-buffer-selected/selected ()
+  (ert-with-test-buffer (:selected t)
+    (should (eq (window-buffer) (current-buffer)))))
+
+(ert-deftest ert-test-with-test-buffer-selected/modification-hooks ()
+  (ert-with-test-buffer (:selected t)
+    (should (null inhibit-modification-hooks))))
+
+(ert-deftest ert-test-with-test-buffer-selected/read-only ()
+  (ert-with-test-buffer (:selected t)
+    (should (null inhibit-read-only))
+    (should (null buffer-read-only))))
+
+(ert-deftest ert-test-with-test-buffer-selected/return-value ()
+  (should (equal (ert-with-test-buffer (:selected t) "foo") "foo")))
+
+(ert-deftest ert-test-with-test-buffer-selected/buffer-name ()
+  (should (equal (ert-with-test-buffer (:name "foo") (buffer-name))
+                 (ert-with-test-buffer (:name "foo" :selected t)
+                   (buffer-name)))))
+
 (provide 'ert-tests)
 
 ;;; ert-tests.el ends here
index aa0edf470590032f2da463ce5f63850bd665a120..7b7abf1ba7e1dbc3f8bd9ee8e7ff7ab47ee755c1 100644 (file)
     (emacs-lisp-mode)
     (should-not (equal (ert-buffer-string-reindented) (buffer-string)))))
 
-(defun ert--hash-table-to-alist (table)
-  (let ((accu nil))
-    (maphash (lambda (key value)
-              (push (cons key value) accu))
-            table)
-    (nreverse accu)))
-
-(ert-deftest ert-test-test-buffers ()
-  (let (buffer-1
-        buffer-2)
-    (let ((test-1
-           (make-ert-test
-            :name 'test-1
-            :body (lambda ()
-                    (ert-with-test-buffer (:name "foo")
-                      (should (string-match
-                               "[*]Test buffer (ert-test-test-buffers): foo[*]"
-                               (buffer-name)))
-                      (setq buffer-1 (current-buffer))))))
-          (test-2
-           (make-ert-test
-            :name 'test-2
-            :body (lambda ()
-                    (ert-with-test-buffer (:name "bar")
-                      (should (string-match
-                               "[*]Test buffer (ert-test-test-buffers): bar[*]"
-                               (buffer-name)))
-                      (setq buffer-2 (current-buffer))
-                      (ert-fail "fail for test"))))))
-      (let ((ert--test-buffers (make-hash-table :weakness t)))
-        (ert-run-tests `(member ,test-1 ,test-2) #'ignore)
-        (should (equal (ert--hash-table-to-alist ert--test-buffers)
-                       `((,buffer-2 . t))))
-        (should-not (buffer-live-p buffer-1))
-        (should (buffer-live-p buffer-2))))))
-
-(ert-deftest ert-test-with-buffer-selected/current ()
-  (let ((origbuf (current-buffer)))
-    (ert-with-test-buffer ()
-      (let ((buf (current-buffer)))
-        (should (not (eq buf origbuf)))
-        (with-current-buffer origbuf
-          (ert-with-buffer-selected buf
-            (should (eq (current-buffer) buf))))))))
-
-(ert-deftest ert-test-with-buffer-selected/selected ()
-  (ert-with-test-buffer ()
-    (ert-with-buffer-selected (current-buffer)
-      (should (eq (window-buffer) (current-buffer))))))
-
-(ert-deftest ert-test-with-buffer-selected/nil-buffer ()
-  (ert-with-test-buffer ()
-    (let ((buf (current-buffer)))
-      (ert-with-buffer-selected nil
-        (should (eq (window-buffer) buf))))))
-
-(ert-deftest ert-test-with-buffer-selected/modification-hooks ()
-  (ert-with-test-buffer ()
-    (ert-with-buffer-selected (current-buffer)
-      (should (null inhibit-modification-hooks)))))
-
-(ert-deftest ert-test-with-buffer-selected/read-only ()
-  (ert-with-test-buffer ()
-    (ert-with-buffer-selected (current-buffer)
-      (should (null inhibit-read-only))
-      (should (null buffer-read-only)))))
-
-(ert-deftest ert-test-with-buffer-selected/return-value ()
-  (should (equal (ert-with-buffer-selected nil "foo") "foo")))
-
-(ert-deftest ert-test-with-test-buffer-selected/selected ()
-  (ert-with-test-buffer (:selected t)
-    (should (eq (window-buffer) (current-buffer)))))
-
-(ert-deftest ert-test-with-test-buffer-selected/modification-hooks ()
-  (ert-with-test-buffer (:selected t)
-    (should (null inhibit-modification-hooks))))
-
-(ert-deftest ert-test-with-test-buffer-selected/read-only ()
-  (ert-with-test-buffer (:selected t)
-    (should (null inhibit-read-only))
-    (should (null buffer-read-only))))
-
-(ert-deftest ert-test-with-test-buffer-selected/return-value ()
-  (should (equal (ert-with-test-buffer (:selected t) "foo") "foo")))
-
-(ert-deftest ert-test-with-test-buffer-selected/buffer-name ()
-  (should (equal (ert-with-test-buffer (:name "foo") (buffer-name))
-                 (ert-with-test-buffer (:name "foo" :selected t)
-                   (buffer-name)))))
-
 (ert-deftest ert-filter-string ()
   (should (equal (ert-filter-string "foo bar baz" "quux")
                  "foo bar baz"))
index 59b8522d6149ffc52d6893a1f18148d3763a3f24..a6b3ecfbd3d73dd85070cdd62a0d155860f9ed2f 100644 (file)
@@ -22,7 +22,6 @@
 ;;; Code:
 
 (require 'ert)
-(require 'ert-x)
 (require 'hideshow)
 
 ;; Dependencies for testing:
index 57804ea2103c4d81c2d05a05c48960da470da5a1..f037f84ad52e71e8e955a3715f0160b0adb4cbeb 100644 (file)
@@ -22,7 +22,6 @@
 ;;; Code:
 
 (require 'ert)
-(require 'ert-x)
 (eval-when-compile (require 'cl-lib))
 
 (defun simple-test--buffer-substrings ()
index a33338c660fea9fb23531a089fd0be824464c983..ed347d04be19327037e2a1ba8d6c08a215d9a9b6 100644 (file)
@@ -19,7 +19,6 @@
 ;;; Code:
 
 (require 'ert)
-(require 'ert-x)
 (require 'faceup)
 (require 'whitespace)