unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Proposal: ert-run-test-at-point
@ 2022-09-09 15:04 Mariano Montone
  2022-09-09 15:08 ` Mariano Montone
  0 siblings, 1 reply; 2+ messages in thread
From: Mariano Montone @ 2022-09-09 15:04 UTC (permalink / raw)
  To: Emacs developers

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




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Proposal: ert-run-test-at-point
  2022-09-09 15:04 Proposal: ert-run-test-at-point Mariano Montone
@ 2022-09-09 15:08 ` Mariano Montone
  0 siblings, 0 replies; 2+ messages in thread
From: Mariano Montone @ 2022-09-09 15:08 UTC (permalink / raw)
  To: Emacs developers

El 9/9/22 a las 12:04, Mariano Montone escribió:
> Hello,
>
> I have this in my .emacs, for quickly running the ert test at cursor 
> point:
>
> ;; run ert test at point
...
>
> (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)))
>
Perhaps calling eval-defun it gets even better:

(defun ert-run-test-at-point ()
   "Run the ert test at point."
   (interactive)
   (eval-defun nil)
   (let* ((test-form (read-from-string (defun-at-point)))
      (test-name (cadar test-form)))
     (ert test-name)))





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-09-09 15:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-09 15:04 Proposal: ert-run-test-at-point Mariano Montone
2022-09-09 15:08 ` Mariano Montone

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).