diff options
author | Alexander Gramiak <agrambot@gmail.com> | 2017-07-13 14:54:35 -0600 |
---|---|---|
committer | Noam Postavsky <npostavs@gmail.com> | 2017-08-07 18:43:54 -0400 |
commit | 054c198c120c1f01a8ff753892d52710b740acc6 (patch) | |
tree | d84b8d8b54cad32fc24cbcf5a60a794eb0d8194d /test/lisp/emacs-lisp | |
parent | e6fa08363dc950e48d72d41fd0f65444d2755ce3 (diff) | |
download | emacs-054c198c120c1f01a8ff753892d52710b740acc6.tar.gz emacs-054c198c120c1f01a8ff753892d52710b740acc6.tar.bz2 emacs-054c198c120c1f01a8ff753892d52710b740acc6.zip |
Catch argument and macroexpansion errors in ert
This kludge catches errors caused by evaluating arguments in ert's
should, should-not, and should-error macros; it also catches
macroexpansion errors inside of the above macros (Bug#24402).
* lisp/emacs-lisp/ert.el: (ert--should-signal-hook): New function.
(ert--expand-should-1): Catch macroexpansion errors.
* test/lisp/emacs-lisp/ert-tests.el (ert-test-should-error-argument)
(ert-test-should-error-macroexpansion): Tests for argument and
expansion errors.
Diffstat (limited to 'test/lisp/emacs-lisp')
-rw-r--r-- | test/lisp/emacs-lisp/ert-tests.el | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/ert-tests.el b/test/lisp/emacs-lisp/ert-tests.el index 57463ad932d..2fbc188dcb9 100644 --- a/test/lisp/emacs-lisp/ert-tests.el +++ b/test/lisp/emacs-lisp/ert-tests.el @@ -294,6 +294,15 @@ failed or if there was a problem." "the error signaled was a subtype of the expected type"))))) )) +(ert-deftest ert-test-should-error-argument () + "Errors due to evaluating arguments should not break tests." + (should-error (identity (/ 1 0)))) + +(ert-deftest ert-test-should-error-macroexpansion () + "Errors due to expanding macros should not break tests." + (cl-macrolet ((test () (error "Foo"))) + (should-error (test)))) + (ert-deftest ert-test-skip-unless () ;; Don't skip. (let ((test (make-ert-test :body (lambda () (skip-unless t))))) |