Skip to content
Permalink
Browse files

Add progress reporter

  • Loading branch information...
liquidz committed May 15, 2019
1 parent f9be43a commit 50e5df15e7cc85fb7ce8a899e061e4ee6a056e56
Showing with 27 additions and 12 deletions.
  1. +3 −2 README.adoc
  2. +24 −10 src/kaocha_nrepl/core.clj
@@ -11,6 +11,7 @@ https://github.com/nrepl/nrepl[nREPL] Middleware for https://github.com/lambdais
image:https://img.shields.io/circleci/project/github/liquidz/kaocha-nrepl/master.svg["CircleCI", link="https://circleci.com/gh/liquidz/kaocha-nrepl"]
image:https://versions.deps.co/liquidz/kaocha-nrepl/status.svg["Dependencies Status", link="https://versions.deps.co/liquidz/kaocha-nrepl"]
image:https://img.shields.io/clojars/v/kaocha-nrepl.svg["Clojars Project", link="https://clojars.org/kaocha-nrepl"]
image:https://img.shields.io/badge/patreon-donate-yellow.svg?logo=Patreon["Become a Patron", link="https://www.patreon.com/uochan"]

== Supports

@@ -26,12 +27,12 @@ image:https://img.shields.io/clojars/v/kaocha-nrepl.svg["Clojars Project", link=

| kaocha-test-all
|
| `config-file`
| `config-file`, `disable-progress-reporter`
| Run all tests.

| kaocha-test
| `testable-ids`
| `config-file`
| `config-file`, `disable-progress-reporter`
| Run tests by `testable-ids`. +
See link:cljdoc.org/d/lambdaisland/kaocha/CURRENT/doc/6-focusing-and-skipping#on-id[kaocha document] for `testable-id`.

@@ -4,25 +4,39 @@
[nrepl.misc :refer [response-for]]
[nrepl.transport :as transport]))

(def ^:private default-progress-format "Testing: %s")

(defn- send! [m msg]
(transport/send (:transport msg) (response-for msg m)))

(defn- test-all-reply [msg]
(let [{:keys [config-file]} msg
config (cond-> {}
config-file (assoc :config-file config-file))]
(-> (kaocha/run-all config)
(merge {:status :done})
(send! msg))))
(defn- progress-reporter [msg test _test-plan]
(let [fmt (:progress-format msg default-progress-format)]
(send! {:out (format fmt (str (:kaocha.testable/id test)))} msg))
test)

(defn- gen-config [msg]
(let [{:keys [config-file disable-progress-reporter]
:or {disable-progress-reporter false}} msg]
(cond-> {}
config-file
(assoc :config-file config-file)

(not disable-progress-reporter)
(assoc :kaocha.hooks/pre-test [(partial progress-reporter msg)]))))

(defn- ensure-list [x]
(cond-> x
(not (sequential? x)) vector))

(defn- test-all-reply [msg]
(-> (gen-config msg)
kaocha/run-all
(merge {:status :done})
(send! msg)))

(defn- test-reply [msg]
(let [{:keys [config-file testable-ids]} msg
config (cond-> {}
config-file (assoc :config-file config-file))
(let [{:keys [testable-ids]} msg
config (gen-config msg)
run-args (some-> testable-ids ensure-list (concat [config]))]
(if run-args
(-> (apply kaocha/run run-args)

0 comments on commit 50e5df1

Please sign in to comment.
You can’t perform that action at this time.