Fork me on GitHub
#kaocha
<
2020-08-21
>
miikka06:08:16

Hey @plexus, did you create another a cljs test runner that is not Kaocha? I have vague recollection of this but now can't find anything

borkdude06:08:24

@miikka personally I’ve been using cljs-test-runner by Olical

borkdude06:08:54

Which mimics the Cognitect labs test runner

plexus08:08:04

@miikka you're thinking of Chui

plexus08:08:42

@borkdude those aren't test runners, they are test runner proof of concepts πŸ˜›

borkdude08:08:17

works for me

miikka08:08:47

Yes, Chui!

plexus08:08:49

which is really just a piece of the puzzle for kaocha-cljs2, but it can also be used standalone, or be a library for other cljs test tooling

plexus08:08:50

I've put a lot more work into kaocha-cljs2 the past few weeks as well, including figuring out how it'll work outside of shadow-cljs.

plexus08:08:28

but it relies on https://clojure.atlassian.net/browse/CLJS-3276 which might take some time to get merged

borkdude09:08:32

@plexus Cool, so CLJS-3276 will allow more dynamic forms of require at compile time (e.g. using env vars etc.)?

plexus09:08:18

you can use env vars already

borkdude09:08:48

I thought CLJS only processes top level require forms outside ns. So how does one do that?

plexus09:08:39

ah yeah no you're right, if you want to generate a require statement with a macro (which may check env vars) then you need this

borkdude09:08:53

yep, so that's neat to have

borkdude09:08:17

I'm doing something very similar to CLJS right now in babashka for creating uberscripts. But CLJS-3276 might be cool to support there as well

plexus09:08:58

currently ClojureScript starts from the top of the files, if it finds an ns form it uses that, if it finds require statements it reads them until it finds some non require statement and then merges them as if it's a single ns form

plexus09:08:14

(technically I think you could have requires followed by an ns, but not the other way around)

borkdude09:08:31

Ah, I thought it supported additional requires after the ns form

plexus09:08:28

so this patch does two things, it continues reading after ns to see if it finds require statements there, or if it finds another form it check if its a macro (based on the previous ns form), if so it loads the macro, analyzes it, and if it turns into a require it processes it

plexus09:08:24

making sure the macro is able to be expanded is the most tricky part because normally loading macros happens in a later pass... I managed to work around it but waiting for David to tell me if this solution is acceptable or if he has other ideas for how to tackle it

plexus09:08:28

the reason we need this is that Chui also uses a macro to inspect the compiler state and find test vars. For that to work we have to be sure that this test-finding-macro only gets compiled after all the tests have been compiled, so conceptually you need this

(ns foo
  (:require alll...your...tests)
  (:require-macros [find-tests!])))

(find-tests!)

plexus09:08:23

but, we don't want to tell people to manually require their tests. That just leads to someone forgetting a test and it never being run. Shadow-cljs has provisions for this, if you use :browser-test or :node-test you can give it a test ns, and it will inject the necessary requires

miikka09:08:46

i'm glad to see this problem tackled outside of shadow-cljs

borkdude09:08:07

I've seen other solutions to create ns forms dynamically at read or compile time, but I think this one is more flexible and applicable to more than just kaocha.

miikka09:08:58

(i mean, the shadow-cljs solution is good too, but not going to migrate all the non-shadow-cljs projects to shadow-cljs when i need to touch them :P)

plexus09:08:04

I tried to propose adding similar functionality to the cljs compiler, but that wasn't warmly received. Instead David said "just use a macro", and I thought, "great", except that it turns out it doesn't work πŸ™‚

plexus09:08:25

so... (inc yak-stack)

borkdude09:08:53

I don't think assuming shadow-cljs everywhere is great. It should be a choice

plexus09:08:49

I know I know... but one of the reasons for kaocha-cljs2 is that we need some way to support people using shadow. Turns out that that is actually pretty easy because shadow has good testing provisions, but now it's a lot more work to support the rest again.

plexus09:08:44

but yeah David agrees that this should work so I'm sure at some point it will work, and then we can support vanilla cljs as well as figwheel, lein-cljsbuild, etc.

plexus09:08:22

the core of the issue of course is that shadow is really a different compiler from all the rest, so if people use shadow then all builds have to be done by shadow. If people use figwheel then we could still do a build with cljs.main as long as we have the same compiler opts

borkdude09:08:37

This is kiiiind of the reason I'm still using cljs-test-runner, although you call it a POC, it works great for my purposes ;)

borkdude09:08:52

But great to hear about the progress

miikka09:08:23

I guess cljs-test-runner is kind of minimum viable test runner

borkdude09:08:50

To be honest, I don't need much

plexus09:08:56

I mean you could use kaocha-cljs, should work just as well. cljs-test-runner is really just a wrapper around doo, which does the compile-everything-to-a-blob thing, which I dislike because it lacks observability

borkdude09:08:04

Same with CIDER: it has tons of features, but I probably only use 5% of them

borkdude09:08:43

@plexus I've tried it but last time I tried it it didn't work with advanced compilation tests

plexus09:08:27

true, it relies on a repl-env which implies :optimizations :none, but that's one of the use cases that kaocha-cljs2 will support

miikka09:08:26

I've now worked a couple of months in this team where we maintain something like 20 services and the clojure/cljs ones just use lein test and Doo, and it works just fine... but if I ever need watching or Doo breaks, I'll introduce Kaocha

miikka09:08:00

but well, it's always the Scala or the JS services that need the attention 😎

plexus10:08:23

@tavistock you can try bin/proj install now if you want to install a local copy of kaocha-junit-xml

πŸ™ 3
plexus10:08:38

➜ bin/proj
Usage: bin/proj [COMMAND] [COMMAND_ARGS...]

  release                            Release a new version to clojars
  pom                                Generate pom files
  install                            Build and install jar(s) locally
  gh_actions_changelog_output        Print the last stanza of the changelog in a format that GH actions understands
  help                               Show this help information
  inspect                            Show expanded opts and exit
  gen-readme                         Generate README based on a template and fill in project variables
  update-readme                      Update sections in README.md
I should release this as a proper tool at some point, but some lambdaisland-specific assumptions are baked in at this point

plexus10:08:50

code is here http://github.com/lambdaisland/open-source/ if you're managing multiple open source projects and you want some unified setup, or if you have projects that consist of multiple sub-projects in one repo then this might be quite useful. I was surprised at the lack of good solutions for building/releasing libraries (and not just applications/uberjars) with deps.edn

plexus10:08:09

A new kaocha-cloverage is out, it just bumps cloverage to 1.2.0, which again seems to contain a bunch of fixes and improvements. Thanks @cksharma122 for doing the upgrade!

πŸ‘ 3
plexus10:08:40

πŸ‘‹:skin-tone-2: hi @bozhidar and @wxitb2017

πŸ‘‹ 3
Lucy Wang10:08:30

Hi @plexus πŸ‘‹, i have been trying chui / kaocha-cljs2 , and it looks really promising! Thanks for the great work.

Lucy Wang11:08:10

One thing that i miss most in shadow-cljs is the ability to only run a subset of tests, seems now I can do it with kaocha-cljs2!

plexus11:08:09

hey that's awesome! kaocha-cljs2 is still pretty fresh but we're using it at Nextjournal and I'm actively working on it. If you find anything that bothers you let me know. Some user reports would be really helpful at this point.

πŸ’― 3
plexus11:08:32

I'll update the docs soon to have some better instructions on how to set things up with or without shadow

πŸ‘ 3
svt11:08:04

Is there a way to specify plugin for specific profile like only for :unit ?

plexus12:08:56

No, plugins operate on a test run.

svt04:08:15

Do you have any plans to have it in future?

plexus09:08:03

No, it's not technically possible. We have a few hooks that fire on the suite level, but most hooks fire once for the whole test run. E.g. what if you enable junit-xml for a single suite, and then run tests across multiple suites? That just doesn't make sense. Maybe explain what you're actually trying to accomplish and I can help figure out how best to do that.

svt09:08:27

Thanks for the explanation :thumbsup: What I’m trying to achieve is not run coverage while running my integration tests. Reason being I have pre-commit hook that checks for coverage threshold. which can fail for integration tests. I want to check coverage threshold only for the unit tests.

plexus11:08:10

I would look either into aero profiles, or set up a second tests.edn

svt14:08:31

I’m not sure about setting up second tests.edn but aero profiles solves my problem πŸ™‚

svt15:08:54

Sorry for a stupid question, but the coverage report is not having colours (everything is coming in white text on terminal) as cloverage report gives. Is there any option that I need to enable?

plexus15:08:35

No idea, I haven't looked at the cloverage stuff in a while...

royalaid19:08:30

Hey @plexus, I am trying to migrate to kaocha-cljs2 and don’t quite see how to plug it together with :node-test and shadow. I see there and node runner and a shadow-cljs runner but it looks like neither of those cover my specific use case

royalaid19:08:25

Okay looks like I am piecing it together a bit, I want to run the :browser-test config

royalaid19:08:17

Okay more piecing together. I can run some tests but those that depend on node.js libs don’t work because we are actually running in the browser

royalaid19:08:43

so I need to feed a node.js processes output to chui which should be running in its own process to render out the ui?

royalaid19:08:59

and this is connected via funnel?

royalaid19:08:03

something also these lines?