[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/assess a459abe966 11/95: New macro `sisyphus-with-prese
From: |
ELPA Syncer |
Subject: |
[elpa] externals/assess a459abe966 11/95: New macro `sisyphus-with-preserved-buffer-list'. |
Date: |
Tue, 19 Jul 2022 15:57:29 -0400 (EDT) |
branch: externals/assess
commit a459abe9661cbc982294b32da3b374117efd534b
Author: Phillip Lord <phillip.lord@newcastle.ac.uk>
Commit: Phillip Lord <phillip.lord@newcastle.ac.uk>
New macro `sisyphus-with-preserved-buffer-list'.
---
sisyphus.el | 33 +++++++++++++++++++++++++++------
test/sisyphus-test.el | 20 ++++++++++++++++++++
2 files changed, 47 insertions(+), 6 deletions(-)
diff --git a/sisyphus.el b/sisyphus.el
index 61af3f1400..2ad29d7e06 100644
--- a/sisyphus.el
+++ b/sisyphus.el
@@ -35,7 +35,7 @@
;; Really, all the functions in here should be tested. But some of the tests
are
;; really, realy hard to test because they depend on the output of ert test,
-;; wh
+
@@ -48,8 +48,16 @@
(require 'pp)
(require 'ert)
(require 'm-buffer-at)
+(require 'dash)
+;; #+end_src
+
+;; #+begin_src emacs-lisp
+(define-error 'deliberate-error
+ "An error deliberately caused during testing."
+ 'error)
;; #+end_src
+
;; ** Advice
@@ -82,6 +90,9 @@
;; How do do this cleanly? Apply patch to ert.el?
+
+
+
;; *** String Comparision
;; #+begin_src emacs-lisp
@@ -214,11 +225,21 @@ print any messages!"
;; ** Create buffers
-;; Need to think carefully about this, but would like to create buffers. Temp
-;; buffers are generally a good option but what if we have a named buffer, but
-;; the named buffer is already open. What happens if a test creates a buffer?
Can
-;; we detect the buffer creation and close them again?
-;; "with-protected-buffer-list" perhaps, or "save-buffer-list-excursion".
+
+(defmacro sisyphus-with-preserved-buffer-list (&rest body)
+ "Evaluate BODY, but delete any buffers that have been created."
+ `(let ((before-buffer-list
+ (buffer-list)))
+ (unwind-protect
+ (progn
+ ,@body)
+ (--map
+ (kill-buffer it)
+ (-difference (buffer-list)
+ before-buffer-list)))))
+
+
+
;; ** Open files
diff --git a/test/sisyphus-test.el b/test/sisyphus-test.el
index 665b9f7352..57c4239832 100644
--- a/test/sisyphus-test.el
+++ b/test/sisyphus-test.el
@@ -152,3 +152,23 @@ This also tests the advice on string=."
(sisyphus-file-string=
sisyphus-test-hello.txt
"goodbye"))))))
+
+
+(ert-deftest preserved-buffer-list ()
+ (should
+ (=
+ (length (buffer-list))
+ (progn
+ (sisyphus-with-preserved-buffer-list
+ (generate-new-buffer "preserved-buffer-list"))
+ (length (buffer-list)))))
+
+ (should
+ (=
+ (length (buffer-list))
+ (condition-case e
+ (sisyphus-with-preserved-buffer-list
+ (generate-new-buffer "preserved-buffer-list")
+ (signal 'deliberate-error nil))
+ (deliberate-error
+ (length (buffer-list)))))))
- [elpa] externals/assess 6a4aa34ec3 33/95: Fixed multiple string matching for face match., (continued)
- [elpa] externals/assess 6a4aa34ec3 33/95: Fixed multiple string matching for face match., ELPA Syncer, 2022/07/19
- [elpa] externals/assess 5dde98a124 31/95: Merge branch 'master' of github.com:phillord/sisyphus, ELPA Syncer, 2022/07/19
- [elpa] externals/assess 0eb198f05e 40/95: Documentation Fix., ELPA Syncer, 2022/07/19
- [elpa] externals/assess c0bdc94e49 41/95: Remove erroneous debug statement., ELPA Syncer, 2022/07/19
- [elpa] externals/assess 2db9834e4e 44/95: Rework Makefile for update to cask, ELPA Syncer, 2022/07/19
- [elpa] externals/assess e820ccf163 05/95: Emacs 24.4 or later., ELPA Syncer, 2022/07/19
- [elpa] externals/assess 3f89d8601f 15/95: Port tests to sisyphus with-temp-buffers., ELPA Syncer, 2022/07/19
- [elpa] externals/assess acb460e26c 16/95: All git-snapshot., ELPA Syncer, 2022/07/19
- [elpa] externals/assess 2e42c93191 06/95: Remove debug statement., ELPA Syncer, 2022/07/19
- [elpa] externals/assess eb56d9627d 07/95: String diff file save is now silent., ELPA Syncer, 2022/07/19
- [elpa] externals/assess a459abe966 11/95: New macro `sisyphus-with-preserved-buffer-list'.,
ELPA Syncer <=
- [elpa] externals/assess 33b6c3c390 12/95: New macro `sisyphus-with-temp-buffers'., ELPA Syncer, 2022/07/19
- [elpa] externals/assess 890906bfcb 17/95: Interface written as single overloaded function., ELPA Syncer, 2022/07/19
- [elpa] externals/assess f3416dadb1 18/95: Indentation test functions., ELPA Syncer, 2022/07/19
- [elpa] externals/assess 1b01542ccd 20/95: Fontification testing., ELPA Syncer, 2022/07/19
- [elpa] externals/assess 2e556a62ae 22/95: Add new test file., ELPA Syncer, 2022/07/19
- [elpa] externals/assess 32a00524a8 24/95: Fix unused variable issues, ELPA Syncer, 2022/07/19
- [elpa] externals/assess 3cf57afcaf 26/95: Merge pull request #1 from syohex/fix, ELPA Syncer, 2022/07/19
- [elpa] externals/assess 00c794a516 29/95: Add package support., ELPA Syncer, 2022/07/19
- [elpa] externals/assess f490f18a18 32/95: Merge branch 'master' of github.com:phillord/sisyphus, ELPA Syncer, 2022/07/19
- [elpa] externals/assess 0d079db1a7 34/95: Completed documentation., ELPA Syncer, 2022/07/19