kaocha

Official support channel: https://clojureverse.org/c/projects/kaocha
plexus 2020-01-23T08:54:27.029300Z

@edenferreira

#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)]
    (-&gt;&gt; (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]
                     (-&gt; suite
                         (update :kaocha/source-paths (partial mapcat glob-scan))
                         (update :kaocha/test-paths (partial mapcat glob-scan)))))))

plexus 2020-01-23T08:55:02.029800Z

it's a little involved because doing glob patterns in java is :poop: , but there you have it

plexus 2020-01-23T08:56:10.030600Z

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.

plexus 2020-01-23T17:14:21.031100Z

[lambdaisland/kaocha-boot "0.0-20"] is out with this fix https://github.com/lambdaisland/kaocha-boot/pull/3. Thanks @jffry !

1❤️