clojure

Jim Newton 2025-11-29T10:42:08.038799Z

I’ve touched on this question in a thread recently as a tangent. asking here for a more thorough treatment. I’d like to get an idea of the code coverage of the test suite for my project. What do I mean by that? I’d like to run the full test suite and thereafter have some sort of report of which lines of code were touched and which lines were not. Hopefully a report on the clojure code rather than the underlying java code. I’d love to hear the advice of anyone who has done this.

Jim Newton 2025-11-30T09:44:04.383499Z

@jumar, that’s an interesting idea… to see how much the code your changed in a PR is covered by tests.

Jim Newton 2025-11-30T09:53:12.266729Z

Yes, quirky, I agree. Is cloverage something people are interested in improving. or is it pretty static? Some of my code which works fine in clojure triggers a TimSort java error in cloverage

Execution error (ClassCastException) at java.util.TimSort/countRunAndMakeAscending (TimSort.java:355).
class clojure.lang.Cons cannot be cast to class java.lang.Comparable (clojure.lang.Cons is in unnamed module of loader 'app'; java.lang.Comparable is in module java.base of loader 'bootstrap')

Jim Newton 2025-11-30T10:19:57.054429Z

most curious

Jim Newton 2025-11-30T11:06:23.885369Z

oops. turns out lein test finds the same TimeSort error. OK, probably my fault. need to investigate

borkdude 2025-11-29T10:44:21.662709Z

https://github.com/cloverage/cloverage

➕ 1
Jim Newton 2025-11-29T10:52:23.753999Z

is the idea that running cloverage will automatically run a wrapped version of lein test?

Jim Newton 2025-11-29T10:52:51.471679Z

I sort of see that implied by the github readme, but it’s not stated explicitly, curiously.

Jim Newton 2025-11-29T11:21:10.971699Z

it seems the parser cloverage is using is not the same parser as in standard clojure. could this be the case? I have some code preceeded by #_ which is treated differently by cloverage vs standard clojure.

Jim Newton 2025-11-29T11:22:36.364979Z

#_(dsdefn f 
  ([[a b] c d] 12)q
  ([a [b c] d] 13)
  ([a b [^Ratio c d]] 14)q
  ([a b [^(satisfies int?) c d]] 15)
  ([a b [^Number c d]] 16)
  ([a b [^Double c d]] 17))
The standard clojure reader does not complain about illegal meta data within a hierarchical structure such as [a b [^(satisfies int?) c d]] in the above example, but cloverage complains and exits.

Jim Newton 2025-11-29T11:28:53.533699Z

perhaps it is trying to intrument the code before ignoring it. i.e. instrument before interpreting #_ ?

Jim Newton 2025-11-29T11:33:39.860259Z

hey! that’s cool

lread 2025-11-29T13:02:49.658949Z

If you are still exploring there is also https://github.com/flow-storm/clofidence

seancorfield 2025-11-29T16:47:18.767949Z

cloverage has a number of weird "holes" and bugs, and doesn't work well with large codebases (or even large functions, I think?). I had to give up trying to use it at work. I haven't tried clofidence yet.

👍🏻 1
lread 2025-11-29T16:57:28.408789Z

I gave clofidence a whirl on etaoin. It is different from cloverage in that it doesn't preserve the original source code format, but it gave me a good enough idea of what was covered.

jumar 2025-11-30T06:38:21.195809Z

We use cloverage on a fairly large codebase at work. It has some quirks but it works reasonably well for us We run it via GitHub actions, even on PRs - to see how much of the changed code is covered by tests.

👍🏻 1