diff --git a/resources/config.edn b/resources/config.edn index 88dd7d4a..94877e11 100644 --- a/resources/config.edn +++ b/resources/config.edn @@ -34,6 +34,7 @@ elin.handler.test/run-test-under-cursor elin.handler.test/run-tests-in-ns elin.handler.test/rerun-last-tests + elin.handler.test/rerun-last-failed-tests elin.handler.evaluate/load-current-file elin.handler.internal/healthcheck elin.handler.internal/error diff --git a/src/elin/handler/test.clj b/src/elin/handler/test.clj index 555d14a2..f830ed1e 100644 --- a/src/elin/handler/test.clj +++ b/src/elin/handler/test.clj @@ -11,6 +11,7 @@ [elin.function.sexpr :as e.f.sexpr] [elin.function.storage.test :as e.f.s.test] [elin.handler.evaluate :as e.h.evaluate] + [elin.message :as e.message] [elin.protocol.host :as e.p.host] [elin.protocol.interceptor :as e.p.interceptor] [elin.protocol.nrepl :as e.p.nrepl] @@ -93,10 +94,9 @@ (e.f.s.test/set-last-test-query session-storage query) (assoc ctx :response (e.f.n.test/test-var-query!! nrepl query)))))))) -(defn rerun-last-tests - [{:as elin :component/keys [interceptor session-storage]}] - (let [query (e.f.s.test/get-last-test-query session-storage) - context (-> (e.u.map/select-keys-by-namespace elin :component) +(defn- run-tests-by-query + [{:as elin :component/keys [interceptor]} query] + (let [context (-> (e.u.map/select-keys-by-namespace elin :component) (assoc :ns (or (:ns query) "") :line (or (:base-line query) 0) :column 0 @@ -113,3 +113,17 @@ (e.f.n.cider/test-var-query!! nrepl query) (e.f.n.test/test-var-query!! nrepl query))] (assoc ctx :response resp)))))) + +(defn rerun-last-tests + [{:as elin :component/keys [session-storage]}] + (->> (e.f.s.test/get-last-test-query session-storage) + (run-tests-by-query elin))) + +(m/=> rerun-last-failed-tests [:=> [:cat e.s.handler/?Elin] any?]) +(defn rerun-last-failed-tests + [{:as elin :component/keys [host session-storage]}] + (let [query (e.f.s.test/get-last-failed-tests-query session-storage)] + (if (and query + (seq (:vars query))) + (run-tests-by-query elin query) + (e.message/warning host "There are no failed tests to rerun."))))