kaocha

Official support channel: https://clojureverse.org/c/projects/kaocha
reefersleep 2020-11-27T00:16:16.149600Z

Is such a thing as cljc tests possible? That is, tests that run in both cljs and clj. (I want to test some macros that are defined in cljc πŸ™‚ )

reefersleep 2020-11-27T22:27:40.159800Z

Cool, a different way to do it. How do you run them?

reefersleep 2020-11-28T23:28:28.162800Z

It’s probably obvious to people more well versed with clj and deps.edn - I’m still getting into it.

plexus 2020-11-30T07:20:43.163Z

standard kaocha stuff, see tests.edn and bin/kaocha

reefersleep 2020-11-30T08:49:12.164800Z

Right you are πŸ™‚ Thanks.

reefersleep 2020-11-27T00:55:29.149800Z

Turns out it is; HoneySQL is a library with such tests! https://clojurians.slack.com/archives/C03S1KBA2/p1606436180241300

plexus 2020-11-27T07:22:07.150100Z

Are you on the latest version? looking at the changelog kaocha.repl should call post-summary starting from 1.0.658

plexus 2020-11-27T07:22:26.150300Z

Thanks! merged!

🍻 1
plexus 2020-11-27T07:23:22.150500Z

Sure, we do this for instance in lambdaisland.uri , using kaocha and kaocha-cljs https://github.com/lambdaisland/uri

plexus 2020-11-27T07:24:11.150800Z

it shouldn't have been an issue for so long... glad that it's fixed now.

2020-11-27T09:52:58.151800Z

I've done a first crude attempt to retry tests automatically https://github.com/lambdaisland/kaocha/pull/176 It's not really working as hoped for and I would it's a bad idea to do it that way, but so for I could not think of another way.

plexus 2020-11-27T10:29:46.154400Z

That's cool @andrea.crotti. Why don't you go ahead and release this yourself? the whole point of the plugin infrastructure is that anyone can release a plugin. That way it's easy and cheap for people to experiment with ideas. Once it's in core we are committed to supporting it forever, and to not break or change its existing behavior.

2020-11-27T10:30:23.154500Z

yeah well I didn't open the PR to merge it sorry (that's why it's just a draft)

2020-11-27T10:30:37.154700Z

just to have something to show to understand what I'm doing wrong

2020-11-27T10:30:50.154900Z

but yeah eventually when it works I can deploy it myself surely

2020-11-27T10:31:08.155100Z

but it's quite far from actually working atm

2020-11-27T10:31:22.155300Z

I'd just like to understand if you have any suggestions about how you would do that

plexus 2020-11-27T10:33:03.155600Z

sure, I would start by using a more fine grained hook. Do you absolutely want to run all tests first before retrying, or is it also fine to retry a failing test immediately?

plexus 2020-11-27T10:35:00.155800Z

you're using post-run which returns a full nested test plan, you'll need a lot more logically to correctly deal with that. If you can use post-test then you can deal with one test at a time

plexus 2020-11-27T10:35:30.156Z

you might also be interested in kaocha.result/failed? or kaocha.result/failed-one?

2020-11-27T10:37:19.156200Z

ah yes I haven't tried post-test but that looks more suitable

2020-11-27T10:37:31.156400Z

and yeah I saw failed? but I needed to get the l ist of failed tests

2020-11-27T10:37:37.156600Z

which I could not get from failed?

plexus 2020-11-27T10:38:00.156800Z

(filter failed-one? (test-seq ...)) doesn't work?

2020-11-27T10:38:14.157Z

ah good point I didn't try that

2020-11-27T10:38:45.157200Z

and the other question is how to make the reporting work (discarding the runs where the test failed)

2020-11-27T10:39:24.157400Z

but maybe if I use the other more granular hook it will work directly

plexus 2020-11-27T10:39:27.157600Z

that's harder... you'll have to intercept the reporting events first, and then replay them if necessary

2020-11-27T10:39:51.157800Z

ah ok yeah I see

2020-11-27T10:40:09.158Z

and last question is if makes sense to use kaocha.repl/run in a plugin

plexus 2020-11-27T10:40:22.158200Z

you can use pre-report to intercept reporting events, change failing events to succeeding for instance, then replay the failure if all retries fail

plexus 2020-11-27T10:40:46.158400Z

alternatively you can use wrap-run to temporarily rebind the reporter...

2020-11-27T10:41:01.158600Z

ah cool yeah lots of possibilities

2020-11-27T10:41:15.158800Z

ok thanks I'll try a few more things

plexus 2020-11-27T10:41:16.159Z

hmmm no I wouldn't use repl/run in a plugin. The repl namespace is really only meant for direct repl use, not as an API

2020-11-27T10:41:41.159200Z

ah yeah I thought it wasn't a great idea

plexus 2020-11-27T10:42:15.159400Z

if you want to re-run single test/testable testable/run-testable is your friend