Skip to content

Commit

Permalink
feat: Add rerun-last-failed-tests handler
Browse files Browse the repository at this point in the history
  • Loading branch information
liquidz committed Jul 28, 2024
1 parent 5df135d commit 324233d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions resources/config.edn
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 18 additions & 4 deletions src/elin/handler/test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand All @@ -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."))))

0 comments on commit 324233d

Please sign in to comment.