summaryrefslogtreecommitdiff
path: root/test/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 /test/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 'test/lisp/emacs-lisp')
-rw-r--r--test/lisp/emacs-lisp/ert-tests.el6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/ert-tests.el b/test/lisp/emacs-lisp/ert-tests.el
index 1a8c9bf4f08..e2b41297ade 100644
--- a/test/lisp/emacs-lisp/ert-tests.el
+++ b/test/lisp/emacs-lisp/ert-tests.el
@@ -495,6 +495,12 @@ This macro is used to test if macroexpansion in `should' works."
(should (equal (ert-select-tests '(tag b) (list test)) (list test)))
(should (equal (ert-select-tests '(tag c) (list test)) '()))))
+(ert-deftest ert-test-select-undefined ()
+ (let* ((symbol (make-symbol "ert-not-a-test"))
+ (data (should-error (ert-select-tests symbol t)
+ :type 'ert-test-unbound)))
+ (should (eq (cadr data) symbol))))
+
;;; Tests for utility functions.
(ert-deftest ert-test-parse-keys-and-body ()