diff options
author | Mattias EngdegÄrd <mattiase@acm.org> | 2021-11-18 12:18:24 +0100 |
---|---|---|
committer | Mattias EngdegÄrd <mattiase@acm.org> | 2021-11-18 12:25:34 +0100 |
commit | 67ffcc5c7f5e1adcc6f662b01c7904f977dd4f51 (patch) | |
tree | 6720fd3b0f59dd44048c2a1fff9cd79f66c17aae /lisp/emacs-lisp | |
parent | f41c6a70e7ce100b13ff0b662a054f6a0cd11cb2 (diff) | |
download | emacs-67ffcc5c7f5e1adcc6f662b01c7904f977dd4f51.tar.gz emacs-67ffcc5c7f5e1adcc6f662b01c7904f977dd4f51.tar.bz2 emacs-67ffcc5c7f5e1adcc6f662b01c7904f977dd4f51.zip |
Signal an error for duplicated ERT tests (bug#51941)
Make `ert-deftest` fail with an error (in batch mode only) if an
existing test is redefined, because that is an easy mistake to make
and which leads to a test being discarded silently.
lisp/emacs-lisp/ert.el (ert-set-test, ert-deftest): Add check.
etc/NEWS: Announce.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r-- | lisp/emacs-lisp/ert.el | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el index 36b4408dc8e..dc9cbc47458 100644 --- a/lisp/emacs-lisp/ert.el +++ b/lisp/emacs-lisp/ert.el @@ -151,6 +151,10 @@ in batch mode.") ;; Note that nil is still a valid value for the `name' slot in ;; ert-test objects. It designates an anonymous test. (error "Attempt to define a test named nil")) + (when (and noninteractive (get symbol 'ert--test)) + ;; Make sure duplicated tests are discovered since the older test would + ;; be ignored silently otherwise. + (error "Test `%s' redefined" symbol)) (define-symbol-prop symbol 'ert--test definition) definition) @@ -206,6 +210,9 @@ Macros in BODY are expanded when the test is defined, not when it is run. If a macro (possibly with side effects) is to be tested, it has to be wrapped in `(eval (quote ...))'. +If NAME is already defined as a test and Emacs is running +in batch mode, an error is signalled. + \(fn NAME () [DOCSTRING] [:expected-result RESULT-TYPE] \ [:tags \\='(TAG...)] BODY...)" (declare (debug (&define [&name "test@" symbolp] |