summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaylor R Campbell <campbell+paredit@mumble.net>2020-11-30 15:23:46 +0000
committerTaylor R Campbell <campbell+paredit@mumble.net>2020-11-30 15:23:46 +0000
commitc6300b9cbe01570f6a64ef7b46dffd557ecddfd1 (patch)
tree413aece20e55d792181701502d0d9ba6884260dd
parent8330a41e8188fe18d3fa805bb9aa529f015318e8 (diff)
Batch up test failures and implement expected-failure.
-rw-r--r--test.el23
1 files changed, 19 insertions, 4 deletions
diff --git a/test.el b/test.el
index 1ddd551..d37d92f 100644
--- a/test.el
+++ b/test.el
@@ -19,9 +19,13 @@
;; You should have received a copy of the GNU General Public License
;; along with paredit. If not, see <http://www.gnu.org/licenses/>.
+(defvar paredit-test-nfailures 0)
+(setq paredit-test-nfailures 0)
+
(defun paredit-test-failure-default (command before after expected)
- (error "%S failed test: after %S, got %S but expected %S."
- command before after expected))
+ (setq paredit-test-nfailures (+ 1 paredit-test-nfailures))
+ (warn "%S failed test: after %S, got %S but expected %S."
+ command before after expected))
(defvar paredit-test-failure-function 'paredit-test-failure-default
"Function to call when `paredit-test' fails.
@@ -35,7 +39,10 @@ Four arguments: the paredit command, the text of the buffer
(defun paredit-test (command examples)
(message "Testing %S..." command)
(dolist (example examples)
- (let ((before (car example)))
+ (let* ((xfail
+ (and (eq (car example) 'xfail)
+ (progn (setq example (cdr example)) t)))
+ (before (car example)))
(dolist (expected (cdr example))
(with-temp-buffer
(paredit-test-buffer-setup)
@@ -56,7 +63,12 @@ Four arguments: the paredit command, the text of the buffer
(insert ?\|)
(not (string= expected (buffer-string))))
(t (error "Bad test expectation: %S" expected)))
- (paredit-test-failed command before (buffer-string) expected)))
+ (if (not xfail)
+ (let ((actual (buffer-string)))
+ (paredit-test-failed command before actual expected)))
+ (if xfail
+ (let ((actual (buffer-string)))
+ (paredit-test-failed command before actual 'failure)))))
(setq before expected)))))
(defun paredit-test-buffer-setup ()
@@ -1499,3 +1511,6 @@ Four arguments: the paredit command, the text of the buffer
"\n(f xy\n z\n w)\n;;;T |"
"\n(f xy\n z\n w)\n;;;|T "
"\n(f xy\n z\n w)\n;;;|T "))))
+
+(if (> paredit-test-nfailures 0)
+ (error "%S paredit tests failed" paredit-test-nfailures))