From 3c7ba7dfbeffc9bc098a3f974db8d4a0c6ae6ffc Mon Sep 17 00:00:00 2001 From: James Suchy Date: Fri, 22 Mar 2024 13:27:45 +0000 Subject: [PATCH] Adds runner-fn for :speclj to support cloverage. --- README.md | 3 ++- deps.edn | 3 ++- src/speclj/cloverage.clj | 19 +++++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 src/speclj/cloverage.clj diff --git a/README.md b/README.md index 135cc45..0fa86e4 100644 --- a/README.md +++ b/README.md @@ -315,6 +315,7 @@ Clone the master branch, build, and run all the tests: ```bash $ git clone https://github.com/slagyr/speclj.git $ cd speclj +$ clj -T:build javac $ clj -M:test:spec ``` @@ -341,4 +342,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. \ No newline at end of file diff --git a/deps.edn b/deps.edn index 09460ec..cc61348 100644 --- a/deps.edn +++ b/deps.edn @@ -5,6 +5,7 @@ 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 { @@ -25,4 +26,4 @@ :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 new file mode 100644 index 0000000..258d008 --- /dev/null +++ b/src/speclj/cloverage.clj @@ -0,0 +1,19 @@ +(ns speclj.cloverage + (:require [cloverage.coverage :as coverage] + [speclj.config :refer [*reporters* *runner*]] + [speclj.report.documentation] + [speclj.results :as results] + [speclj.run.standard] + [speclj.running :refer [run-and-report]]) + (:import (speclj.report.documentation DocumentationReporter) + (speclj.run.standard StandardRunner))) + +(defmethod coverage/runner-fn :speclj [_opts] + (fn [nses] + (let [results (atom []) + runner (StandardRunner. (atom []) results) + reporters [(DocumentationReporter.)]] + (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