From 86f1f5f3dd3358e1bb557a02465017e48b9e23a1 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Mon, 30 Nov 2020 16:30:29 +0000 Subject: Stop each test on first failure or unexpected success. --- test.el | 56 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 26 deletions(-) (limited to 'test.el') diff --git a/test.el b/test.el index 539f8b2..07389a6 100644 --- a/test.el +++ b/test.el @@ -43,33 +43,37 @@ Four arguments: the paredit command, the text of the buffer (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) - (insert before) - (goto-char (point-min)) - (if (search-forward "_" nil t) - (progn (delete-char -1) (set-mark (point)))) - (goto-char (point-min)) - (search-forward "|") - (delete-char -1) - (if (cond ((eq expected 'error) - ;++ Check that there are no more expected states. - (condition-case condition - (progn (call-interactively command) t) - (error nil))) - ((stringp expected) - (call-interactively command) - (insert ?\|) - (not (string= expected (buffer-string)))) - (t (error "Bad test expectation: %S" expected))) - (if (not xfail) + (catch 'break + (dolist (expected (cdr example)) + (with-temp-buffer + (paredit-test-buffer-setup) + (insert before) + (goto-char (point-min)) + (if (search-forward "_" nil t) + (progn (delete-char -1) (set-mark (point)))) + (goto-char (point-min)) + (search-forward "|") + (delete-char -1) + (if (cond ((eq expected 'error) + ;++ Check that there are no more expected states. + (condition-case condition + (progn (call-interactively command) t) + (error nil))) + ((stringp expected) + (call-interactively command) + (insert ?\|) + (not (string= expected (buffer-string)))) + (t (error "Bad test expectation: %S" expected))) + (progn + (if (not xfail) + (let ((actual (buffer-string))) + (paredit-test-failed command before actual expected))) + (throw 'break nil)) + (if 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))))) + (paredit-test-failed command before actual 'failure) + (throw 'break nil))))) + (setq before expected)))))) (defun paredit-test-buffer-setup () (scheme-mode) -- cgit v1.2.1