From 018d40ed3d409fdf82b51a12f0a294b3670c7af0 Mon Sep 17 00:00:00 2001 From: Micah Date: Fri, 22 Mar 2024 13:27:29 -0700 Subject: [PATCH] 3.4.6 candidate that includes cloverage plugin and readme docs --- README.md | 27 ++++++++++++++++++++++----- VERSION | 2 +- deps.edn | 17 +++++++++-------- src/speclj/cloverage.clj | 16 +++++++++------- 4 files changed, 41 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 0fa86e4..839714d 100644 --- a/README.md +++ b/README.md @@ -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"] ``` @@ -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"]}} } ``` @@ -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/) @@ -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. \ No newline at end of file +Distributed under the The MIT License. diff --git a/VERSION b/VERSION index 4f5e697..1cf8253 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.4.5 +3.4.6 diff --git a/deps.edn b/deps.edn index cc61348..c19ba52 100644 --- a/deps.edn +++ b/deps.edn @@ -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"]} @@ -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}"} } } - } \ No newline at end of file + } diff --git a/src/speclj/cloverage.clj b/src/speclj/cloverage.clj index 258d008..401ed84 100644 --- a/src/speclj/cloverage.clj +++ b/src/speclj/cloverage.clj @@ -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)}))) \ No newline at end of file + {:errors (results/fail-count @results)})))