kaocha

Piotr Roterski 2022-03-10T12:19:24.920509Z

hello πŸ‘‹ I made a tiny PR bumping glogi version in chai https://github.com/lambdaisland/chui/pull/19 - just letting you know in case you missed it, thank you

plexus 2022-03-10T13:49:54.467259Z

hey, I do have that sitting in my inbox! will have it merged soon.

Piotr Roterski 2022-03-10T14:20:04.142219Z

ah, great, thank you and I’m not trying to urge you in any way, I’m patient and grateful for your OSS work. I just know it’s easy to overlook those github notifications hence my message here.

❀️ 1
plexus 2022-03-10T16:48:48.152379Z

merged it, will try to cut a release tomorrow

πŸŽ‰ 1
miikka 2022-03-10T07:35:14.183779Z

Hmm, bin/kaocha <testsuite> is running all test suites but bin/kaocha --focus <testsuite> runs just the specified. one. I thought these should do the same thing?

imre 2022-03-10T09:26:18.152349Z

ooh polylith + kaocha! We've just began migrating services to polylith and as we currently use kaocha as a test runner I'd love to learn about others' experience with the combination

miikka 2022-03-10T09:36:39.545989Z

I'm in the same situation...

imre 2022-03-10T09:40:55.893429Z

Check this issue out then: https://github.com/polyfy/polylith/issues/126 - my mid term plan is to fork/extend the polylith tool so that one could plug in their own test runner to be used via poly test so poly can do all its classpath magic but would leave test discovery and execution to something like kaocha if plugged

miikka 2022-03-10T09:47:43.566139Z

Yeah, that would be nice

miikka 2022-03-10T09:47:57.505849Z

@plexus Here's a simplified repro of my setup https://github.com/miikka/kaocha-focus-repro

plexus 2022-03-10T10:33:33.308559Z

@miikka if polylith is generating the config then verify that it looks correct with --print-config

plexus 2022-03-10T10:36:55.522939Z

had a look at the repro, if you do --focus suite-a you can see that the suite-b is getting marked as skipped: :kaocha.testable/skip true,, that seems to not be happening when doing bin/kaocha suite-a

plexus 2022-03-10T10:37:16.770019Z

tbh this is a novel use case, completely generating your config in a plugin.

plexus 2022-03-10T10:41:31.893639Z

ok, I think I see what's happening. If you give a suite parameter (so without focusing) it filters that out already in a pre-load load, so that it can skip loading and any other processing for that suite. If you say --focus suite then it loads the full test plan, and then marks the things that are not being focused on as skipped.

miikka 2022-03-10T10:42:30.194079Z

I thought the pre-load would still happen after the config phase?

miikka 2022-03-10T10:44:05.247269Z

I'm not super invested into this approach, it's just occurred to me to try it out when thinking about how to combine Kaocha and Polylith. Polylith's own test runner is not very good (it's just basically clojure.test + magic to construct the right classpath) πŸ˜›

plexus 2022-03-10T10:44:57.358759Z

wait forget what I said

plexus 2022-03-10T10:45:47.191389Z

the test suite handling is handled way at the beginning

plexus 2022-03-10T10:46:56.987179Z

(defn apply-cli-args [config args]
  (if (seq args)
    (-> config
        (assoc :kaocha/cli-args args)
        (update :kaocha/tests
                (fn [tests]
                  (let [run-suite? (set args)]
                    (mapv (fn [{suite-id :kaocha.testable/id :as suite}]
                            (cond-> suite
                              (not (run-suite? suite-id))
                              (assoc :kaocha.testable/skip true)))
                          tests)))))
    config))

plexus 2022-03-10T10:47:15.080339Z

this is before the config hook runs

plexus 2022-03-10T10:48:20.311909Z

we get into these chicken and egg problems sometimes...

plexus 2022-03-10T10:48:58.187449Z

I think what you can try is calling apply-cli-args yourself in your plugin once you have the full config

plexus 2022-03-10T10:49:52.512039Z

it's a workaround but it's not the worst. You should be able to find a :kaocha/cli-args in the config you are given

plexus 2022-03-10T10:50:49.822299Z

It might make sense to pull this apart, only assoc :kaocha/cli-args at the early stage, and then handle the actual filtering later, maybe in the filter plugin

plexus 2022-03-10T10:51:14.196129Z

not sure if this will cause any unwanted change in behavior, it seems a fairly harmless change

miikka 2022-03-10T11:07:55.365459Z

Right, yeah, calling apply-cli-args would work or implementing the same logic with :kaocha/cli-args . Thanks.

imre 2022-03-28T15:20:51.154369Z

@miikka ^

plexus 2022-03-10T07:39:45.304979Z

they should. Can you share your tests.edn and maybe make a gist of the ouptut of bin/kaocha --print-test-plan <testuite>

miikka 2022-03-10T07:47:51.039989Z

Nope. But I'm using a custom plugin (with config hook) to generate :kaocha/tests for our Polylith project, probably something going wrong with that