Skip to content

Commit

Permalink
3.4.6 candidate that includes cloverage plugin and readme docs
Browse files Browse the repository at this point in the history
  • Loading branch information
slagyr committed Mar 22, 2024
1 parent b3d367d commit 018d40e
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 21 deletions.
27 changes: 22 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ Include speclj in your `:dev` profile `:dependencies` and`:plugins`. Then change

```clojure
; - snip
:dependencies [[org.clojure/clojure "1.6.0"]]
:profiles {:dev {:dependencies [[speclj "3.3.0"]]}}
:plugins [[speclj "3.3.0"]]
:dependencies [[org.clojure/clojure "1.11.2"]]
:profiles {:dev {:dependencies [[speclj "3.4.6"]]}}
:plugins [[speclj "3.4.6"]]
:test-paths ["spec"]
```

Expand Down Expand Up @@ -138,7 +138,7 @@ Add a `spec` alias to your `deps.edn`.
```clojure
{
:aliases {:spec {:main-opts ["-m" "speclj.main" "-c"]
:extra-deps {speclj/speclj {:mvn/version "3.4.5"}}
:extra-deps {speclj/speclj {:mvn/version "3.4.6"}}
:extra-paths ["spec"]}}
}
```
Expand Down Expand Up @@ -302,6 +302,23 @@ The command below will start a process that will watch the source files and run
$ bin/speclj path/to/compiled.js
```

# Code Coverage

Speclj integrated with [Cloverage](https://github.com/cloverage/cloverage) for all your code coverage needs. Make sure
speclj 3.4.6 or above is included in the classpath and use Cloverage's `--runner :speclj` command line option.

Here's an example alias for your `deps.edn`.

```clojure
{:aliases {:cov {:main-opts ["-m" "cloverage.coverage" "--runner" ":speclj" "-p" "src" "-s" "spec" ]
:extra-deps {cloverage/cloverage {:mvn/version "1.2.4"}
speclj/speclj {:mvn/version "3.4.6"}}}}}
```

Sadly, Cloverage doesn't offer a way to pass arguments to the runner (Speclj in this case). Speclj will use the
standard runner and progress reporter by default. If you'd like different options, you can use the `speclj.cloverage`
namespace as a model to create your own cloverage/speclj runner in your project.

# Community

* API Documentaiton [http://micahmartin.com/speclj/](http://micahmartin.com/speclj/)
Expand Down Expand Up @@ -342,4 +359,4 @@ Post issues on the speclj github project:
# License
Copyright (C) 2010-2023 Micah Martin All Rights Reserved.

Distributed under the The MIT License.
Distributed under the The MIT License.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.4.5
3.4.6
17 changes: 9 additions & 8 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
mmargs/mmargs {:mvn/version "1.2.0"}
org.clojure/clojure {:mvn/version "1.11.1"}
trptcolin/versioneer {:mvn/version "0.1.1"}
cloverage/cloverage {:mvn/version "1.2.4"}
}
:aliases {
:test {:extra-deps {
io.github.clojure/tools.build {:mvn/version "0.9.5"}
org.clojure/clojurescript {:mvn/version "1.11.60"}
io.github.clojure/tools.build {:mvn/version "0.9.5"}
org.clojure/clojurescript {:mvn/version "1.11.60"}
cloverage/cloverage {:mvn/version "1.2.4"}
}
:extra-paths ["dev" "spec" "target/classes"]}
:spec {:main-opts ["-m" "speclj.main" "-c"]}
Expand All @@ -19,11 +19,12 @@
clj-commons/pomegranate {:mvn/version "1.2.23"}}
:ns-default build
:extra-paths ["dev"]}
:cov {:main-opts ["-m" "cloverage.coverage" "--runner" ":speclj" "-p" "src" "-s" "spec" "-e" "leiningen.spec" "--foo" "bar"]}
:codox {:extra-deps {codox/codox {:mvn/version "0.10.8"}}
:exec-fn codox.main/generate-docs
:exec-args {:source-paths ["src"]
:output-path "doc"
:source-uri "https://github.com/slagyr/speclj/blob/master/{filepath}#L{line}"}
:exec-fn codox.main/generate-docs
:exec-args {:source-paths ["src"]
:output-path "doc"
:source-uri "https://github.com/slagyr/speclj/blob/master/{filepath}#L{line}"}
}
}
}
}
16 changes: 9 additions & 7 deletions src/speclj/cloverage.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@
(:require [cloverage.coverage :as coverage]
[speclj.config :refer [*reporters* *runner*]]
[speclj.report.documentation]
[speclj.report.progress :as progress]
[speclj.results :as results]
[speclj.run.standard]
[speclj.running :refer [run-and-report]])
(:import (speclj.report.documentation DocumentationReporter)
(speclj.run.standard StandardRunner)))
[speclj.run.standard :as standard]
[speclj.running :refer [run-and-report]]))

;; Assumes that cloverage is already in the classpath.

(defmethod coverage/runner-fn :speclj [_opts]
(prn "_opts: " _opts)
(fn [nses]
(let [results (atom [])
runner (StandardRunner. (atom []) results)
reporters [(DocumentationReporter.)]]
runner (standard/->StandardRunner (atom []) results)
reporters [(progress/->ProgressReporter)]]
(binding [*runner* runner *reporters* reporters]
(apply require (map symbol nses))
(run-and-report runner reporters))
{:errors (results/fail-count @results)})))
{:errors (results/fail-count @results)})))

0 comments on commit 018d40e

Please sign in to comment.