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.
This commit is contained in:
Philipp Stephani 2021-12-30 16:59:16 +01:00
parent 94891dd225
commit f6da1eed74
3 changed files with 16 additions and 2 deletions

View file

@ -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 ()