Test coverage for Clojure: the project's Lazytest run under ClojureStorm and Clofidence.
ClojureStorm is a Clojure compiler that reports each expression it runs, and
Clofidence records those reports. A coverage run adds both to the project's own
test command through one extra deps.edn alias, :vis-coverage. A Lazytest hook
in that alias writes the recorded forms as EDN, because the test JVM has no JSON
library. This process then turns them into the vis-coverage/1 JSON report that
graphify crap reads:
{"format": "vis-coverage/1", "tool": "clofidence", "prefixes": [...],
"forms": [{"file": "app/core.clj", "ns": "app.core", "line": 3,
"kind": "defn", "hittable": 12, "hit": 9,
"children": {"4": [5, 5]}}]}
file is classpath-relative. hittable counts the expressions the compiler
instrumented in the top-level form, and hit the ones that ran. children
gives the same counts for each direct element of the form, keyed by its index,
so a tool can score each method of a defrecord or an extend-type.
Test coverage for Clojure: the project's Lazytest run under ClojureStorm and
Clofidence.
ClojureStorm is a Clojure compiler that reports each expression it runs, and
Clofidence records those reports. A coverage run adds both to the project's own
test command through one extra deps.edn alias, `:vis-coverage`. A Lazytest hook
in that alias writes the recorded forms as EDN, because the test JVM has no JSON
library. This process then turns them into the `vis-coverage/1` JSON report that
`graphify crap` reads:
{"format": "vis-coverage/1", "tool": "clofidence", "prefixes": [...],
"forms": [{"file": "app/core.clj", "ns": "app.core", "line": 3,
"kind": "defn", "hittable": 12, "hit": 9,
"children": {"4": [5, 5]}}]}
`file` is classpath-relative. `hittable` counts the expressions the compiler
instrumented in the top-level form, and `hit` the ones that ran. `children`
gives the same counts for each direct element of the form, keyed by its index,
so a tool can score each method of a `defrecord` or an `extend-type`.(alias-edn prefixes)The -Sdeps value that adds the :vis-coverage alias.
The `-Sdeps` value that adds the `:vis-coverage` alias.
The Clofidence release that records the coverage.
The Clofidence release that records the coverage.
(default-prefixes root)The namespace prefixes to instrument: for each top-level segment of the project's source namespaces, the prefix that its namespaces share.
The namespace prefixes to instrument: for each top-level segment of the project's source namespaces, the prefix that its namespaces share.
(finish! root prefixes)Turn the recorded forms into the report and summarize it. An error names a
run that recorded nothing.
Turn the recorded forms into the report and summarize it. An `error` names a run that recorded nothing.
Where the hook writes the recorded forms, under the project root.
Where the hook writes the recorded forms, under the project root.
The source path that holds the hook namespace, under the project root.
The source path that holds the hook namespace, under the project root.
The Lazytest hook that records coverage.
The Lazytest hook that records coverage.
(instrument-command cmd prefixes)cmd, a clojure ... -M:aliases args... vector, run under the coverage alias
with the hook. Nil when cmd has no -M alias argument.
`cmd`, a `clojure ... -M:aliases args...` vector, run under the coverage alias with the hook. Nil when `cmd` has no `-M` alias argument.
(prepare! root)Write the hook namespace and remove the forms of an earlier run.
Write the hook namespace and remove the forms of an earlier run.
(report forms prefixes)The vis-coverage/1 report of the recorded forms that [[measured?]] keeps.
The `vis-coverage/1` report of the recorded `forms` that [[measured?]] keeps.
The vis-coverage/1 report, under the project root.
The `vis-coverage/1` report, under the project root.
The ClojureStorm compiler release, a drop-in replacement for org.clojure/clojure.
The ClojureStorm compiler release, a drop-in replacement for org.clojure/clojure.
(summary root report)Covered and measured expressions of each file in report.
Covered and measured expressions of each file in `report`.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |