From: Glenn Morris <rgm@gnu.org>
To: 25931-done@debbugs.gnu.org
Subject: bug#25931: 25.1; ERT "show messages" error
Date: Thu, 02 Mar 2017 15:42:36 -0500 [thread overview]
Message-ID: <noy3wn4dhf.fsf@fencepost.gnu.org> (raw)
In-Reply-To: <877f4855wp.fsf@aol.com> (Live System User's message of "Thu, 02 Mar 2017 05:28:38 -0500")
Version: 26.1
commit dacafa8
Date: Thu Mar 2 15:40:15 2017 -0500
Ert commands to error if no test at point (bug#25931)
* lisp/emacs-lisp/ert.el (ert-results-mode-menu):
Deactivate some items if no test at point.
(ert--results-test-at-point-no-redefinition):
Add option to signal an error rather than return nil.
(ert-results-pop-to-backtrace-for-test-at-point)
(ert-results-pop-to-messages-for-test-at-point)
(ert-results-pop-to-should-forms-for-test-at-point)
(ert-results-describe-test-at-point): Error if no test at point.
diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el
index 785f4ac..cadd66c 100644
--- a/lisp/emacs-lisp/ert.el
+++ b/lisp/emacs-lisp/ert.el
@@ -2079,14 +2079,23 @@ and how to display message."
'("ERT Results"
["Re-run all tests" ert-results-rerun-all-tests]
"--"
- ["Re-run test" ert-results-rerun-test-at-point]
- ["Debug test" ert-results-rerun-test-at-point-debugging-errors]
- ["Show test definition" ert-results-find-test-at-point-other-window]
+ ;; FIXME? Why are there (at least) 3 different ways to decide if
+ ;; there is a test at point?
+ ["Re-run test" ert-results-rerun-test-at-point
+ :active (car (ert--results-test-at-point-allow-redefinition))]
+ ["Debug test" ert-results-rerun-test-at-point-debugging-errors
+ :active (car (ert--results-test-at-point-allow-redefinition))]
+ ["Show test definition" ert-results-find-test-at-point-other-window
+ :active (ert-test-at-point)]
"--"
- ["Show backtrace" ert-results-pop-to-backtrace-for-test-at-point]
- ["Show messages" ert-results-pop-to-messages-for-test-at-point]
- ["Show `should' forms" ert-results-pop-to-should-forms-for-test-at-point]
- ["Describe test" ert-results-describe-test-at-point]
+ ["Show backtrace" ert-results-pop-to-backtrace-for-test-at-point
+ :active (ert--results-test-at-point-no-redefinition)]
+ ["Show messages" ert-results-pop-to-messages-for-test-at-point
+ :active (ert--results-test-at-point-no-redefinition)]
+ ["Show `should' forms" ert-results-pop-to-should-forms-for-test-at-point
+ :active (ert--results-test-at-point-no-redefinition)]
+ ["Describe test" ert-results-describe-test-at-point
+ :active (ert--results-test-at-point-no-redefinition)]
"--"
["Delete test" ert-delete-test]
"--"
@@ -2237,22 +2246,24 @@ To be used in the ERT results buffer."
(and (ert-test-boundp sym)
sym))))
-(defun ert--results-test-at-point-no-redefinition ()
+(defun ert--results-test-at-point-no-redefinition (&optional error)
"Return the test at point, or nil.
-
+If optional argument ERROR is non-nil, signal an error rather than return nil.
To be used in the ERT results buffer."
(cl-assert (eql major-mode 'ert-results-mode))
- (if (ert--results-test-node-or-null-at-point)
- (let* ((node (ert--results-test-node-at-point))
- (test (ert--ewoc-entry-test (ewoc-data node))))
- test)
- (let ((progress-bar-begin ert--results-progress-bar-button-begin))
- (when (and (<= progress-bar-begin (point))
- (< (point) (button-end (button-at progress-bar-begin))))
- (let* ((test-index (- (point) progress-bar-begin))
- (test (aref (ert--stats-tests ert--results-stats)
+ (or
+ (if (ert--results-test-node-or-null-at-point)
+ (let* ((node (ert--results-test-node-at-point))
+ (test (ert--ewoc-entry-test (ewoc-data node))))
+ test)
+ (let ((progress-bar-begin ert--results-progress-bar-button-begin))
+ (when (and (<= progress-bar-begin (point))
+ (< (point) (button-end (button-at progress-bar-begin))))
+ (let* ((test-index (- (point) progress-bar-begin))
+ (test (aref (ert--stats-tests ert--results-stats)
test-index)))
- test)))))
+ test))))
+ (if error (user-error "No test at point"))))
(defun ert--results-test-at-point-allow-redefinition ()
"Look up the test at point, and check whether it has been redefined.
@@ -2377,7 +2388,7 @@ To be used in the ERT results buffer."
To be used in the ERT results buffer."
(interactive)
- (let* ((test (ert--results-test-at-point-no-redefinition))
+ (let* ((test (ert--results-test-at-point-no-redefinition t))
(stats ert--results-stats)
(pos (ert--stats-test-pos stats test))
(result (aref (ert--stats-test-results stats) pos)))
@@ -2406,7 +2417,7 @@ To be used in the ERT results buffer."
To be used in the ERT results buffer."
(interactive)
- (let* ((test (ert--results-test-at-point-no-redefinition))
+ (let* ((test (ert--results-test-at-point-no-redefinition t))
(stats ert--results-stats)
(pos (ert--stats-test-pos stats test))
(result (aref (ert--stats-test-results stats) pos)))
@@ -2427,7 +2438,7 @@ To be used in the ERT results buffer."
To be used in the ERT results buffer."
(interactive)
- (let* ((test (ert--results-test-at-point-no-redefinition))
+ (let* ((test (ert--results-test-at-point-no-redefinition t))
(stats ert--results-stats)
(pos (ert--stats-test-pos stats test))
(result (aref (ert--stats-test-results stats) pos)))
@@ -2554,7 +2565,7 @@ To be used in the ERT results buffer."
To be used in the ERT results buffer."
(interactive)
- (ert-describe-test (ert--results-test-at-point-no-redefinition)))
+ (ert-describe-test (ert--results-test-at-point-no-redefinition t)))
;;; Actions on load/unload.
prev parent reply other threads:[~2017-03-02 20:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-02 10:28 bug#25931: 25.1; ERT "show messages" error Live System User
2017-03-02 20:42 ` Glenn Morris [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=noy3wn4dhf.fsf@fencepost.gnu.org \
--to=rgm@gnu.org \
--cc=25931-done@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.