Is there a (built-in) way to make kaocha detect :source-paths and :test-paths automatically? Or take them from deps.edn?
I have split my code into multiple sub-projects and would like to run all tests. For that, my :test alias has all sub/x/test directories in :extra-paths. I do not want to repeat all these paths in tests.edn.
there's nothing built in for that, you could make a plugin for that or do it through a hook
OK, thanks!
Just wanted to come back here to share the quick and dirty solution I came up with, and to say thank you @plexus for making Kaocha awesome and extensible. I was surprised how easy that was! 💪
Here is the gist of my pre-load hook:
(require '[clojure.java.classpath :as cp])
(defn- classpath-test-paths
"Finds all 'test' directories on the classpath."
[]
(into []
(comp (filter #(= "test" (.getName %)))
(map #(.getPath %)))
(cp/classpath-directories)))
(defn pre-load-classpath-test-paths
"Kaocha pre-load hook to set test-paths from the classpath."
[config]
;; Quick and dirty -- YMMV
(assoc-in config [:kaocha/tests 0 :kaocha/test-paths] (classpath-test-paths)))
…and then this line in tests.edn and done:
:kaocha.hooks/pre-load [my.kaocha.hooks/pre-load-classpath-test-paths]very cool!