yes, so @plexus FYI I got it all working (test splitting with circleci and kaocha test plan)
(def found (atom []))
(defn fetch-tests
[test-plan]
(reset! found [])
(w/postwalk
#(do
(when (= :kaocha.type/ns (:kaocha.testable/type %))
(swap! found conj %))
%)
test-plan)
(->> @found
(map :kaocha.testable/id)
sort))
(defn tests-to-run
[]
(-> (sh/sh "circleci"
"tests"
"split"
"--split-by=timings"
:in (s/join "\n" (map name (fetch-tests (kr/test-plan)))))
:out
(s/split #"\n")))
(defn -main
[& _args]
(let [result (apply kr/run
(conj (vec (tests-to-run))
{:plugin :kaocha.plugin/junit-xml
:junit-xml-file "test-results/kaocha/results.xml"}))]
(System/exit
(if (or (pos? (:kaocha.result/error result))
(pos? (:kaocha.result/fail result)))
1
0))))
I think it can be improved and maybe I can avoid that atom
but it seems to work well now
in the end I actually just needed to extract the namespaces not the actual tests
very cool! can you also share you .circleci
config?
I just have this alias in project.clj
"ci-tests" ["run" "-m" "finops.ci-tests"]
and circleci is just somethin glike
kstream-tests:
parallelism: 4
resource_class: large
docker:
- image: *lein
working_directory: ~/finops-kstreams
steps:
- checkout
- *restore-cache
- run: lein ci-tests
- store_test_results:
path: test-results
I can maybe write a blog post about this or some docs in kaocha though
but I think that the test reporting (the failure summary) is not working properly though
maybe this plugin config is not right
(apply kr/run
(conj (vec (tests-to-run))
{:plugin :kaocha.plugin/junit-xml
:junit-xml-file "test-results/kaocha/results.xml"}))
:plugin
should be :plugins
and should be a vector
and :junit-xml-file should be a namespaced keyword
:kaocha.plugin.junit-xml/target-file
ah cool thanks, would it be possible to add specs to kaocha? Or it's not done just to support older versions of Clojure as well?
we have specs, but specs are open so using wrong keys won't be detected
some fat-finger detection would be great so we can warn on misspellings, I looked into that at some point but couldn't find anything that was quick to integrate. Maybe there are better options now.
and I guess not all plugins add specs for their config keys, that would be great to have too
feel free to open issues for these things, I plan to curate them at some point to have a set of beginner friendly issues, and these might be good for that
ok thanks, yeah I think it's a bit hard to understand what to pass to kr/run for example
https://cljdoc.org/d/lambdaisland/kaocha/1.0.641/api/kaocha.repl
doc improvements are always very welcome, but most of this stuff is documented
Bruce Hauman has a spell check library for this purpose.
Although in Figwheel it fails, might be tweakable