[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
ERT / find-function type integration typos
From: |
Stephen Gildea |
Subject: |
ERT / find-function type integration typos |
Date: |
Wed, 15 Jan 2025 13:21:03 -0800 |
There appears to be some confusion in both find-func.el and
ert.el as to what "type" and regexp to use when searching for
a test defined with 'ert-deftest'. This confusion is masked
by find-function-search-for-symbol doing some clever fallback
searching.
In various places, both "ert-deftest" and "ert--test" are used
as the object type. The type must match the symbol property
used (for symbol-file), so "ert--test" is the correct type.
I have fixed uses of "ert-deftest".
This patch also fixes a problem where the button created by
ert-describe-test passes nil as the type. Again, this error
is masked by find-function-search-for-symbol using a fallback
search.
This look right to people?
< Stephen
diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el
index f25ba8a529c..5d9230fa3cf 100644
--- a/lisp/emacs-lisp/ert.el
+++ b/lisp/emacs-lisp/ert.el
@@ -1355,7 +1355,7 @@ ert-test-location
(when-let* ((loc
(ignore-errors
(find-function-search-for-symbol
- (ert-test-name test) 'ert-deftest (ert-test-file-name
test)))))
+ (ert-test-name test) 'ert--test (ert-test-file-name test)))))
(let* ((buffer (car loc))
(point (cdr loc))
(file (file-relative-name (buffer-file-name buffer)))
@@ -2467,7 +2467,9 @@ ert-results-find-test-at-point-other-window
(defun ert--test-name-button-action (button)
"Find the definition of the test BUTTON belongs to, in another window."
- (let ((name (button-get button 'ert-test-name)))
+ ;; work with either ert-insert-test-name-button or help-xref-button
+ (let ((name (or (button-get button 'ert-test-name)
+ (car (button-get button 'help-args)))))
(ert-find-test-other-window name)))
(defun ert--ewoc-position (ewoc node)
@@ -2814,7 +2816,8 @@ ert-describe-test
(file-name-nondirectory file-name)))
(save-excursion
(re-search-backward (substitute-command-keys "`\\([^`']+\\)'"))
- (help-xref-button 1 'help-function-def test-name file-name)))
+ (help-xref-button 1 'ert--test-name-button
+ test-name file-name)))
(insert ".")
(fill-region-as-paragraph (point-min) (point))
(insert "\n\n")
@@ -2855,7 +2858,7 @@ ert-results-describe-test-at-point
(defun ert--unload-function ()
"Unload function to undo the side-effects of loading ert.el."
- (ert--remove-from-list 'find-function-regexp-alist 'ert-deftest :key #'car)
+ (ert--remove-from-list 'find-function-regexp-alist 'ert--test :key #'car)
(ert--remove-from-list 'minor-mode-alist 'ert--current-run-stats :key #'car)
(ert--remove-from-list 'emacs-lisp-mode-hook
'ert--activate-font-lock-keywords)
diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el
index 643b6aba2a6..6a65c2f88c4 100644
--- a/lisp/emacs-lisp/find-func.el
+++ b/lisp/emacs-lisp/find-func.el
@@ -123,15 +123,6 @@ find-alias-regexp
:group 'xref
:version "25.1")
-(defcustom find-ert-deftest-regexp
- "(ert-deftest +'%s"
- "The regexp used to search for an `ert-deftest' definition.
-Note it must contain a `%s' at the place where `format'
-should insert the feature name."
- :type 'regexp
- :group 'xref
- :version "29.1")
-
(defun find-function--defface (symbol)
(catch 'found
(while (re-search-forward (format find-face-regexp symbol) nil t)
@@ -145,8 +136,7 @@ find-function-regexp-alist
(defvar . find-variable-regexp)
(defface . find-function--defface)
(feature . find-feature-regexp)
- (defalias . find-alias-regexp)
- (ert-deftest . find-ert-deftest-regexp))
+ (defalias . find-alias-regexp))
"Alist mapping definition types into regexp variables.
Each regexp variable's value should actually be a format string
to be used to substitute the desired symbol name into the regexp.
- ERT / find-function type integration typos,
Stephen Gildea <=