#kaocha/v1
{:plugins [:kaocha.plugin/hooks]
:tests [{:id :unit
:source-paths ["checkouts/**/src"]
:test-paths ["test"]}]
:kaocha.hooks/pre-load [my.kaocha.hooks/expand-globs]}
(ns my.kaocha.hooks
(:import [java.nio.file Files Path FileSystems])
(:require [<http://clojure.java.io|clojure.java.io> :as io]
[clojure.string :as str]))
(defn fs []
(FileSystems/getDefault))
(defn path [s]
(.getPath (fs) s (into-array String [])))
(defn glob-matcher [glob]
(.getPathMatcher (fs) (str "glob:" glob)))
(defn glob-scan [glob]
(let [glob (glob-matcher glob)]
(->> (io/file ".")
file-seq
(filter #(.matches glob (path (str/replace (str %) #"^\./" ""))))
(map str))))
(defn expand-globs [config]
(update config :kaocha/tests
(partial map
(fn [suite]
(-> suite
(update :kaocha/source-paths (partial mapcat glob-scan))
(update :kaocha/test-paths (partial mapcat glob-scan)))))))
it's a little involved because doing glob patterns in java is :poop: , but there you have it
It also seems the hooks plugin does not as of yet support config hooks, that's an oversight, that's why I'm using a pre-load hook instead. I'll add config hooks in the next release.
[lambdaisland/kaocha-boot "0.0-20"]
is out with this fix https://github.com/lambdaisland/kaocha-boot/pull/3. Thanks @jffry !