kaocha

Official support channel: https://clojureverse.org/c/projects/kaocha
2020-07-27T10:30:49.485400Z

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))))

2020-07-27T10:30:56.485700Z

I think it can be improved and maybe I can avoid that atom

2020-07-27T10:31:03.486Z

but it seems to work well now

2020-07-27T10:31:45.486700Z

in the end I actually just needed to extract the namespaces not the actual tests

plexus 2020-07-27T10:39:49.487400Z

very cool! can you also share you .circleci config?

2020-07-27T10:44:18.488100Z

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

2020-07-27T10:44:29.488400Z

I can maybe write a blog post about this or some docs in kaocha though

2020-07-27T10:44:49.489Z

but I think that the test reporting (the failure summary) is not working properly though

2020-07-27T10:45:08.489500Z

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"}))

plexus 2020-07-27T10:46:00.490500Z

:plugin should be :plugins and should be a vector

plexus 2020-07-27T10:46:18.490900Z

and :junit-xml-file should be a namespaced keyword

plexus 2020-07-27T10:46:49.491100Z

:kaocha.plugin.junit-xml/target-file

2020-07-27T10:50:43.491800Z

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?

plexus 2020-07-27T10:51:24.492300Z

we have specs, but specs are open so using wrong keys won't be detected

plexus 2020-07-27T10:52:54.493400Z

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.

plexus 2020-07-27T10:53:25.493900Z

and I guess not all plugins add specs for their config keys, that would be great to have too

plexus 2020-07-27T10:54:07.494600Z

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

2020-07-27T10:57:27.495Z

ok thanks, yeah I think it's a bit hard to understand what to pass to kr/run for example

plexus 2020-07-27T10:59:16.496100Z

doc improvements are always very welcome, but most of this stuff is documented

dominicm 2020-07-27T11:38:11.496200Z

Bruce Hauman has a spell check library for this purpose.

dominicm 2020-07-27T11:38:29.496400Z

Although in Figwheel it fails, might be tweakable