Skip to content
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 @@[nREPL] Middleware for
image:["CircleCI", link=""]
image:["Dependencies Status", link=""]
image:["Clojars Project", link=""]
image:["Become a Patron", link=""]

== Supports

@@ -26,12 +27,12 @@ image:["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[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))

(defn- gen-config [msg]
(let [{:keys [config-file disable-progress-reporter]
:or {disable-progress-reporter false}} msg]
(cond-> {}
(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)
(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.