From 22fed5591568066082b33c2cb7473cd3799de8de Mon Sep 17 00:00:00 2001 From: Psionik K <73710933+psionic-k@users.noreply.github.com> Date: Fri, 3 Nov 2023 18:12:21 +0900 Subject: [PATCH] Preparing to make better test shortcuts Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com> --- lisp/erk.el | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/lisp/erk.el b/lisp/erk.el index 9018652..f104cf6 100644 --- a/lisp/erk.el +++ b/lisp/erk.el @@ -482,26 +482,31 @@ Will reload all features and test features." (defun erk-ert-project-results-buffer () "Return an ERT buffer name based on project name.") +(defun erk--get-ert-test-symbols () + "Return all defined ERT test symbols. +Does not reload." + (let ((test-features (erk--test-features))) + (->> test-features + (-map #'symbol-file) + (--map (cdr (assoc it load-history))) + (-flatten-n 1) + (--filter (eq 'define-symbol-props (car it))) + (-map #'cdr) + (-flatten-n 2) + (--filter (plist-get (symbol-plist it) 'ert--test))))) + (defun erk-ert-project-selector () "Return a selector for just this project's ERT test. This selector generates the symbols list before that selector will run, so new features or new symbols only available after reload will not be picked up. Run this after any necessary feature reloading." - (let* ((test-features (erk--test-features)) - (test-symbols (->> test-features - (-map #'symbol-file) - (--map (cdr (assoc it load-history))) - (-flatten-n 1) - (--filter (eq 'define-symbol-props (car it))) - (-map #'cdr) - (-flatten-n 2)))) - (message "test-symbols: %s" test-symbols) - `(satisfies ,(lambda (test) - (member (ert-test-name test) test-symbols))))) + `(member ,@(erk--get-ert-test-symbols))) ;;;###autoload (defun erk-ert-project () + ;; TODO select failed, automatically when there are failed figure out how to + ;; offer up tags as options. See `ert-select-tests', but it's just okay "Run Ert interactively, with selector for this project." (interactive) (erk-reload-project-package)