This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-01-23
Channels
- # aleph (14)
- # announcements (2)
- # babashka (8)
- # bangalore-clj (2)
- # beginners (66)
- # calva (8)
- # cider (1)
- # clj-kondo (24)
- # cljdoc (3)
- # cljs-dev (3)
- # cljsrn (2)
- # clojure (197)
- # clojure-europe (1)
- # clojure-india (5)
- # clojure-italy (4)
- # clojure-nl (27)
- # clojure-uk (18)
- # clojurescript (56)
- # code-reviews (19)
- # core-async (86)
- # cursive (16)
- # data-science (1)
- # datomic (16)
- # docker (3)
- # events (1)
- # fulcro (101)
- # graalvm (7)
- # graphql (16)
- # jobs (1)
- # jobs-discuss (6)
- # kaocha (4)
- # luminus (1)
- # off-topic (93)
- # onyx (3)
- # pathom (9)
- # planck (2)
- # re-frame (8)
- # reagent (3)
- # reitit (3)
- # remote-jobs (3)
- # shadow-cljs (21)
- # test-check (3)
- # tools-deps (21)
- # vim (16)
#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 [ :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 !
❤️ 4