calva

sirwobin 2025-05-23T11:41:17.971189Z

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. ๐Ÿ™‚

๐Ÿ‘€ 1
sirwobin 2025-05-23T12:51:28.214729Z

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.

sirwobin 2025-05-23T12:54:23.059759Z

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.

sirwobin 2025-05-23T12:55:23.345859Z

So next question: is there a way to specify Calva's test runner behaviour or give it a function to run for all tests?

pez 2025-05-23T13:10:08.840719Z

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.

sirwobin 2025-05-23T13:15:09.499209Z

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.

sirwobin 2025-05-23T13:20:28.265389Z

Actually, looks like cider.nrepl.middleware.test/handle-test is where to look

pez 2025-05-23T13:21:16.870059Z

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.

pez 2025-05-23T13:15:56.601569Z

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

๐Ÿ™ 1
Shantanu Kumar 2025-05-23T04:21:24.489159Z

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?

pez 2025-05-23T05:56:35.418009Z

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.

Shantanu Kumar 2025-05-23T06:05:31.034809Z

@pez Thank you, will explore this. One vscode instance per deps.edn/project-root sounds reasonable.