That's a cool idea. We definitely want that on the namespace level, never thought about doing it on the function level.
That would be awesome, I've heard of this as "Test Impact Analysis": https://martinfowler.com/articles/rise-test-impact-analysis.html
@plexus do you happen to know if all the hooks are their to do make that kind of thing work with plugins?
I could see it being especially useful for property-based tests, which tend to (necessarily) take a while to run
you should be able to do this with plugins just fine, just a matter of figuring out which tests should be skipped
Jest does something similar. It will check what files have been modified in version control and trace the dependency graph to decide what files to rerun. I’m not sure what level it walks the dependency graph at though — if it is namespace or function level.
Midje does this as well in its autotest features, it just uses the dependency graph to limit the namespaces to run. There's a branch somewhere with a PoC for Kaocha https://nextjournal.com/lambdaisland/kaocha-autotest
this is one of the projects we proposed for RGSoC, but not that likely we'll have a team this year so it's up for grabs if anyone is interested to have a go at it.
Oh neat.
For kaocha-cljs, is the right thing to try here to simply bump up the timeout?
Exception: clojure.lang.ExceptionInfo: Failed initializing ClojureScript runtime {:kaocha.testable/id :cljs, :cljs/repl-env cljs.repl.node/repl-env, :cljs/compiler-options {:target :nodejs}, :eval-done? true, :ws/connected? true}
I’ll give the instructions under “https://github.com/lambdaisland/kaocha-cljs#debugging” a shot first, but it’s a bit gnarly because it’s only happening in CI.
When using kaocha, is there an equivalent to -n
from the cognitect test runner or :only
from leiningen, from the command line?
nm, got it: https://cljdoc.org/d/lambdaisland/kaocha/1.0.632/doc/6-focusing-and-skipping#on-a-namespace
I'm trying to port this:
clojure -A:test -n babashka.pods.jvm-test
;;=>
clojure -A:test:kaocha --focus babashka.pods.jvm-test
clojure -A:sci:test -n babashka.pods.sci-test
;;=>
clojure -A:sci:test:kaocha --focus babashka.pods.sci-test
This one:
clojure -A:test:kaocha --focus babashka.pods.jvm-test
doesn't work, since the sci library is (deliberately!) not available on the classpath. The code should run without the library, which is part of my test.With the Cognitest test runner or leiningen that works, but with kaocha it doesn't:
$ clojure -A:test:kaocha --focus babashka.pods.jvm-test
WARNING: :focus [:babashka.pods.jvm-test] did not match any tests.
[E]
Randomized with --seed 2027872620
ERROR in unit (babashka/pods/sci.clj:1)
Exception: clojure.lang.Compiler$CompilerException: Syntax error compiling at (babashka/pods/sci.clj:1:1).
#:clojure.error{:phase :compile-syntax-check, :line 1, :column 1, :source "babashka/pods/sci.clj"}
So my proposal would be that focus should not load files other than it needs.