Skip to content

Commit

Permalink
refactor(ert): use sexp helper to get test name
Browse files Browse the repository at this point in the history
  • Loading branch information
martini97 committed Jun 29, 2023
1 parent a8bf3a5 commit 095abb5
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions testrun-ert.el
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,15 @@
;;; Code:

(require 'testrun-core)
(require 'testrun-sexp)

(defun testrun-ert--get-test-name-at-point ()
"Get the name of the current test at point.
If the point is not within a test, than throw user error.
The logic of this function was borrowed from
https://github.com/tonini/overseer.el"
(save-excursion
(end-of-defun)
(beginning-of-defun)
(if-let* ((fn-raw (read (current-buffer)))
(fn-name (car fn-raw))
((string= "ert-deftest" fn-name)))
(symbol-name (cadr fn-raw))
(user-error "No test at point"))))
"Get the name of the current test at point."
(if-let ((test-at-point (car (seq-map #'cadr (testrun-sexp--filter-car-memq
(testrun-sexp--parents)
'(ert-deftest))))))
test-at-point
(user-error "No test at point")))

;;;###autoload
(defun testrun-ert-get-test (scope)
Expand Down

0 comments on commit 095abb5

Please sign in to comment.