Hi folks. I have a project setup with deps.edn and I'm using the cognitect test runner. I annotate integration tests with a keyword and using an alias I can run only those from the command line like clj -Mtest --include :integration. Since the alias that I use for calva must open a repl, I can't specify an :exec-fn or see any cli options that will restrict the test runner to ignore integration tests when using the IDE. Does anyone else have a similar test split and if so, how do you configure the test runner to ignore certain tests while in the IDE? Thank you. ๐
I can run (cognitect.test-runner.api/test {:excludes #{:integration}}) from the repl, which gets me where I need to be. At worst this means the calva hotkeys are not useful.
Hmm, this also means that the integration which figures out which tests are failing as well as failing test navigation hotkeys are also useless. ๐ The correct tests run and output is sent to stdout which appears in the repl output prefixed by semicolons.
So next question: is there a way to specify Calva's test runner behaviour or give it a function to run for all tests?
If cider-nrepl has a way to configure this we can add it to Calva. You could ask about this in #nrepl where also the cider-nrepl wizards are Otherwise. Calvaโs test runner will only run test symbols that are evaluated. So if you can find out a way to only evaluate the symbols you want to run, then maybe you can use the regular test runner when in the IDE and use the Cognitect runner when not. I am speculating here. I donโt have much experience with test runners other than the Clojure one and the shadow-cljs runner.
That's a great hint, thanks! I'll let you know what I find. If you could point me to that part of the calva code where it invokes tests using cider I'll have a better idea of what to ask and how to interpret the answers.
Actually, looks like cider.nrepl.middleware.test/handle-test is where to look
It happens on line 666 (๐ฟ ๐ฑ ) here: https://github.com/BetterThanTomorrow/calva/blob/dev/src/nrepl/index.ts And also the VarQuery interface in https://github.com/BetterThanTomorrow/calva/blob/dev/src/nrepl/cider.ts A way to get a feel for it is to enable nrepl logging in Calva and see the message exchange when you run tests.
Dear Calva friends, new Calva out: https://github.com/BetterThanTomorrow/calva/releases/tag/v2.0.514 โข Fix: https://github.com/BetterThanTomorrow/calva/issues/2848 Mostly this is so that Backseat Driver powered AI Agents can quicker figure out that the REPL isnโt connected. calva
Hi. Is it possible to specify which deps.edn alias (or Leiningen profile) to use for code/dependencies for clojure-LSP or Jack-in REPL in a project?
I think so. Jack-in starts with a menu asking for project root, if there are more than one deps.edn etc file. For lsp Calva can start servers in different parts of the project. But for both cases, I think it is most often better to create one overarching deps.edn which uses local-root to reference the subprojects. Then use that one to get over repl to reach all projects. Another thing I often do is to open a vscode window in the subproject. Then different windows have their own reply and lsp servers.
@pez Thank you, will explore this. One vscode instance per deps.edn/project-root sounds reasonable.