summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorPhilipp Stephani <phst@google.com>2021-12-30 16:59:16 +0100
committerPhilipp Stephani <phst@google.com>2021-12-30 17:06:09 +0100
commitf6da1eed7447c363ef927fea9b23a7b35587473c (patch)
treec4dae7cf0d7d3da8100bb7df26c5ea319bb55753 /lisp/emacs-lisp
parent94891dd225c7e74b89588814b6f8b11cec633659 (diff)
downloademacs-f6da1eed7447c363ef927fea9b23a7b35587473c.tar.gz
emacs-f6da1eed7447c363ef927fea9b23a7b35587473c.tar.bz2
emacs-f6da1eed7447c363ef927fea9b23a7b35587473c.zip
Properly report errors about unbound ERT test symbols.
Assertions should only be used to check internal consistency within a package, not to check arguments passed by callers. Instead, define and use a new error symbol. * lisp/emacs-lisp/ert.el (ert-test-unbound): New error symbol. (ert-select-tests): Use it. * test/lisp/emacs-lisp/ert-tests.el (ert-test-select-undefined): New unit test. * etc/NEWS: Document new behavior.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/ert.el9
1 files changed, 7 insertions, 2 deletions
diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el
index c5701328704..da14b93d1bf 100644
--- a/lisp/emacs-lisp/ert.el
+++ b/lisp/emacs-lisp/ert.el
@@ -1012,7 +1012,8 @@ contained in UNIVERSE."
universe))))
((pred ert-test-p) (list selector))
((pred symbolp)
- (cl-assert (ert-test-boundp selector))
+ (unless (ert-test-boundp selector)
+ (signal 'ert-test-unbound (list selector)))
(list (ert-get-test selector)))
(`(,operator . ,operands)
(cl-ecase operator
@@ -1020,7 +1021,9 @@ contained in UNIVERSE."
(mapcar (lambda (purported-test)
(pcase-exhaustive purported-test
((pred symbolp)
- (cl-assert (ert-test-boundp purported-test))
+ (unless (ert-test-boundp purported-test)
+ (signal 'ert-test-unbound
+ (list purported-test)))
(ert-get-test purported-test))
((pred ert-test-p) purported-test)))
operands))
@@ -1059,6 +1062,8 @@ contained in UNIVERSE."
(cl-remove-if-not (car operands)
(ert-select-tests 't universe)))))))
+(define-error 'ert-test-unbound "ERT test is unbound")
+
(defun ert--insert-human-readable-selector (selector)
"Insert a human-readable presentation of SELECTOR into the current buffer."
;; This is needed to avoid printing the (huge) contents of the