emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Proposal: ert-run-test-at-point


From: Mariano Montone
Subject: Proposal: ert-run-test-at-point
Date: Fri, 9 Sep 2022 12:04:51 -0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]