cider-nrepl
cider-nrepl copied to clipboard
`middleware.test`: offer fail-fast functionality
It would be sweet to offer fail-fast functionality. Under it:
- The first failing failing test var fails that ns; and
- The first failing ns fails the test run.
Relevant code:
https://github.com/clojure-emacs/cider-nrepl/blob/a740583c3aa8b582f3097611787a276775131d32/src/cider/nrepl/middleware/test.clj#L238-L239
https://github.com/clojure-emacs/cider-nrepl/blob/a740583c3aa8b582f3097611787a276775131d32/src/cider/nrepl/middleware/test.clj#L260-L263
Some inspiration:
(defn run-tests
"Like clojure.test/run-tests, but fails fast."
[& namespaces]
(let [summary (-> (->> namespaces
(reduce (bound-fn [r n]
(let [{:keys [fail error]
:as v} (clojure.test/test-ns n)
failed? (some pos? [fail error])
ret (merge-with + r v)]
(cond-> ret
failed? reduced)))
clojure.test/*initial-report-counters*))
(assoc :type :summary))]
(clojure.test/do-report summary)
summary))
Yeah, that'd be great. It has been on the TODO list for as long as the middleware existed, alongside async reporting of the progress. The fail-fast is definitely easier to implement, though.