From: Eshel Yaron Date: Thu, 16 Jan 2025 08:45:22 +0000 (+0100) Subject: Use ert-deftest instead of ert--test consistently X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=3ef4bd2de7c31b2a0d673217df10fbe26325dec6;p=emacs.git Use ert-deftest instead of ert--test consistently --- diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el index bbefa7c788c..f892e12fa86 100644 --- a/lisp/emacs-lisp/ert.el +++ b/lisp/emacs-lisp/ert.el @@ -131,12 +131,11 @@ mode.") (defun ert-test-boundp (symbol) "Return non-nil if SYMBOL names a test." - (and (get symbol 'ert--test) t)) + (get symbol 'ert-deftest)) (defun ert-get-test (symbol) "If SYMBOL names a test, return that. Signal an error otherwise." - (unless (ert-test-boundp symbol) (error "No test named `%S'" symbol)) - (get symbol 'ert--test)) + (or (ert-test-boundp symbol) (error "No test named `%S'" symbol))) (defun ert-set-test (symbol definition) "Make SYMBOL name the test DEFINITION, and return DEFINITION." @@ -149,16 +148,16 @@ 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)) + (when (and noninteractive (ert-test-boundp symbol)) ;; Make sure duplicated tests are discovered since the older test would ;; be ignored silently otherwise. (error "Test `%s' redefined (or loaded twice)" symbol)) - (define-symbol-prop symbol 'ert--test definition) + (define-symbol-prop symbol 'ert-deftest definition) definition) (defun ert-make-test-unbound (symbol) "Make SYMBOL name no test. Return SYMBOL." - (cl-remprop symbol 'ert--test) + (cl-remprop symbol 'ert-deftest) symbol) (defun ert--parse-keys-and-body (keys-and-body) @@ -1543,7 +1542,7 @@ test packages depend on each other, it might be helpful.") ;; https://www.ibm.com/docs/en/developer-for-zos/14.1.0?topic=formats-junit-xml-format ;; https://llg.cubic.org/docs/junit/ (when-let ((symbol (car (apropos-internal "" #'ert-test-boundp))) - (test-file (symbol-file symbol 'ert--test)) + (test-file (symbol-file symbol 'ert-deftest)) (test-report (file-name-with-extension (or ert-load-file-name test-file) "xml"))) @@ -2803,7 +2802,7 @@ To be used in the ERT results buffer." (insert (if test-name (format "%S" test-name) "")) (insert " is a test") (let ((file-name (and test-name - (symbol-file test-name 'ert--test)))) + (symbol-file test-name 'ert-deftest)))) (when file-name (insert (format-message " defined in `%s'" (file-name-nondirectory file-name))) diff --git a/test/lisp/emacs-lisp/ert-tests.el b/test/lisp/emacs-lisp/ert-tests.el index cd89536f6a0..d60d9479c2b 100644 --- a/test/lisp/emacs-lisp/ert-tests.el +++ b/test/lisp/emacs-lisp/ert-tests.el @@ -352,7 +352,7 @@ This macro is used to test if macroexpansion in `should' works." (let ((abc (ert-get-test 'ert-test-abc))) (should (equal (ert-test-tags abc) '(bar))) (should (equal (ert-test-documentation abc) "foo"))) - (should (equal (symbol-file 'ert-test-deftest 'ert--test) + (should (equal (symbol-file 'ert-test-deftest 'ert-deftest) (symbol-file 'ert-test--which-file 'defun))) (ert-deftest ert-test-def () :expected-result ':passed) diff --git a/test/lisp/erc/resources/erc-scenarios-common.el b/test/lisp/erc/resources/erc-scenarios-common.el index 8e50225e0a0..259b2b46930 100644 --- a/test/lisp/erc/resources/erc-scenarios-common.el +++ b/test/lisp/erc/resources/erc-scenarios-common.el @@ -250,7 +250,7 @@ Dialog resource directories are located by expanding the variable (insert buf))) (kill-emacs (ert-stats-completed-unexpected stats)))))) ;; The `ert-test' object in Emacs 29 has a `file-name' field. - (file-name (symbol-file name 'ert--test)) + (file-name (symbol-file name 'ert-deftest)) (default-directory (expand-file-name (file-name-directory file-name))) (package (if-let* ((found (getenv "ERC_PACKAGE_NAME")) ((string-prefix-p "erc-" found))) diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index dd1779b5e81..0bb81c188e7 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -3861,12 +3861,12 @@ This tests also `access-file', `file-readable-p', "Set the documentation string for a derived test. The test is derived from TEST and COMMAND." (let ((test-doc - (split-string (ert-test-documentation (get test 'ert--test)) "\n"))) + (split-string (ert-test-documentation (get test 'ert-deftest)) "\n"))) ;; The first line must be extended. (setcar test-doc (format "%s Use the \"%s\" command." (car test-doc) command)) (setf (ert-test-documentation - (get (intern (format "%s-with-%s" test command)) 'ert--test)) + (get (intern (format "%s-with-%s" test command)) 'ert-deftest)) (string-join test-doc "\n")))) (defmacro tramp--test-deftest-with-stat (test) @@ -3945,7 +3945,7 @@ The test is derived from TEST and COMMAND." :tags '(:expensive-test) (let ((test-doc (split-string - (ert-test-documentation (get ',test 'ert--test)) "\n"))) + (ert-test-documentation (get ',test 'ert-deftest)) "\n"))) ;; The first line must be extended. (setcar test-doc @@ -3953,7 +3953,7 @@ The test is derived from TEST and COMMAND." (setf (ert-test-documentation (get (intern (format "%s-without-file-attributes" ',test)) - 'ert--test)) + 'ert-deftest)) (string-join test-doc "\n"))) (skip-unless (tramp--test-enabled)) (skip-unless @@ -5122,7 +5122,7 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'." `(ert-deftest ,(intern (concat (symbol-name test) "-direct-async")) () ;; This is the docstring. However, it must be expanded to a ;; string inside the macro. No idea. - ;; (concat (ert-test-documentation (get ',test 'ert--test)) + ;; (concat (ert-test-documentation (get ',test 'ert-deftest)) ;; "\nUse direct async process.") :tags (append '(:expensive-test :tramp-asynchronous-processes) (and ,unstable '(:unstable)))