From: Mariano Montone <marianomontone@gmail.com>
To: Emacs developers <emacs-devel@gnu.org>
Subject: Proposal: ert-run-test-at-point
Date: Fri, 9 Sep 2022 12:04:51 -0300 [thread overview]
Message-ID: <b07eca76-f942-8606-8fe1-6cdfcb869fab@gmail.com> (raw)
Hello,
I have this in my .emacs, for quickly running the ert test at cursor point:
;; run ert test at point
(defun defun-at-point ()
"Return the text of the defun at point."
(apply #'buffer-substring-no-properties
(region-for-defun-at-point)))
(defun region-for-defun-at-point ()
"Return the start and end position of defun at point."
(save-excursion
(save-match-data
(end-of-defun)
(let ((end (point)))
(beginning-of-defun)
(list (point) end)))))
(defun ert-run-test-at-point ()
"Run the ert test at point."
(interactive)
(let* ((test-form (read-from-string (defun-at-point)))
(test-name (cadar test-form)))
(ert test-name)))
Then I bind ert-run-test-at-point to C-c C-t (locally to the buffer with
the tests), and I'm able to quickly run the tests at cursor point as I
write them.
I think it would be cool if something like this came by default with ERT.
Mariano
next reply other threads:[~2022-09-09 15:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-09 15:04 Mariano Montone [this message]
2022-09-09 15:08 ` Proposal: ert-run-test-at-point Mariano Montone
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b07eca76-f942-8606-8fe1-6cdfcb869fab@gmail.com \
--to=marianomontone@gmail.com \
--cc=emacs-devel@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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).