kaocha

Official support channel: https://clojureverse.org/c/projects/kaocha
plexus 2019-08-26T10:09:02.095100Z

@jvtrigueros that's not currently implemented, but is straightforward with a plugin.

plexus 2019-08-26T10:09:17.095400Z

quick untested example:

plexus 2019-08-26T10:09:20.095700Z

(ns jvtrigueros.kaocha-plugins
  (:require [clojure.string :as str]))

(defn- accumulate [m k v]
  (update m k (fnil conj []) v))

(defn- parse-binding [s]
  (let [[k & vs] (str/split s #"=")
        v (str/join "=" vs)]
    [k v]))

(def cli-opts
  [nil "--binding" "Configure a dynamic binding, syntax dynamic.var/name=edn-value".
   :parse-fn parse-binding
   :assoc-fn accumulate])

(defplugin jvtrigueros.kaocha-plugins/cli-bindings
  (cli-options [opts]
    (conj opts cli-opts))

  (config [config]
    (let [bindings (get-in config [:kaocha/cli-options :binding])]
      (update config :kaocha/bindings #(into (or % {}) bindings)))))

plexus 2019-08-26T10:11:07.096900Z

put that under src/ and try it out with kaocha --plugin jvtrigueros.kaocha-plugins/cli-bindings --binding my.var=[1,2,3] --print-config

plexus 2019-08-26T12:29:50.097500Z

It would perhaps even be better to just have --binding take an edn map

2019-08-26T12:59:50.097800Z

Sweet! Thanks!

plexus 2019-08-26T13:13:26.098200Z

ah and you'll have to :refer [defplugin] 🙂

2019-08-26T13:16:14.099200Z

Lemme give it a shot. Essentially I want to toggle some var when testing locally vs ci

plexus 2019-08-26T14:06:39.100600Z

ok, in that case I would also look at the features that aero gives you. e.g. create a tests-ci.edn, containing #merge #include "tests.edn" {:kaocha/bindings {...}}

plexus 2019-08-26T14:07:09.101Z

and then run bin/kaocha --config-file tests-ci.edn on CI

plexus 2019-08-26T14:09:03.102Z

actually this makes me think we could do some cool stuff with aero's profiles, having a --profile cli flag, and defaulting to a profile of :ci when CI=true (which travis/circle/... all set)

2019-08-26T14:10:42.102700Z

Ah I didn’t know I could do this. Thanks!