From 8a33ad0332d69bedf35427d6d81dd3e65b39c597 Mon Sep 17 00:00:00 2001 From: Alexander McKenna Date: Mon, 22 Sep 2025 17:02:28 +0100 Subject: [PATCH] Add extra fail threshold arguments for cloverage --- CHANGELOG.md | 5 ++++- README.md | 4 +++- src/kaocha/plugin/cloverage.clj | 14 ++++++++++++++ test/unit/kaocha/plugin/cloverage_test.clj | 12 ++++++++++++ 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3cee833..7591a94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## Added +- Add `--cov-{line,form}-fail-threshold` to specify the cloverage + `:{line,form}-fail-threshold` parameters. + ## Fixed ## Changed @@ -87,4 +90,4 @@ ## Changed -- Initial release \ No newline at end of file +- Initial release diff --git a/README.md b/README.md index 10fa49a..831d086 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,8 @@ Alternatively Cloverage can be configured through `tests.edn`. Source paths spec :lcov? false, :high-watermark 80, :fail-threshold 0, + :line-fail-threshold 0, + :form-fail-threshold 0, :output "target/coverage", :low-watermark 50, :ns-regex [], @@ -135,4 +137,4 @@ changes are justified. Copyright © 2018-2020 Arne Brasseur and contributors Available under the terms of the Eclipse Public License 1.0, see LICENSE.txt - \ No newline at end of file + diff --git a/src/kaocha/plugin/cloverage.clj b/src/kaocha/plugin/cloverage.clj index bf0542e..9268d72 100644 --- a/src/kaocha/plugin/cloverage.clj +++ b/src/kaocha/plugin/cloverage.clj @@ -20,6 +20,8 @@ :coveralls? false :summary? true :fail-threshold 0 + :line-fail-threshold 0 + :form-fail-threshold 0 :low-watermark 50 :high-watermark 80 :nop? false @@ -46,6 +48,12 @@ ["--cov-fail-threshold PERCENT" "Sets the percentage threshold at which cloverage will abort the build. Default: 0%" :parse-fn #(Integer/parseInt %)] + ["--cov-line-fail-threshold PERCENT" + "Sets the percentage threshold at which cloverage will abort the build. Default: 0%" + :parse-fn #(Integer/parseInt %)] + ["--cov-form-fail-threshold PERCENT" + "Sets the percentage threshold at which cloverage will abort the build. Default: 0%" + :parse-fn #(Integer/parseInt %)] ["--cov-low-watermark PERCENT" "Sets the low watermark percentage (valid values 0..100). Default: 50%" :parse-fn #(Integer/parseInt %)] @@ -103,6 +111,12 @@ (contains? opts :cov-fail-threshold) (assoc :fail-threshold (:cov-fail-threshold opts)) + (contains? opts :cov-line-fail-threshold) + (assoc :line-fail-threshold (:cov-line-fail-threshold opts)) + + (contains? opts :cov-form-fail-threshold) + (assoc :form-fail-threshold (:cov-form-fail-threshold opts)) + (contains? opts :cov-low-watermark) (assoc :low-watermark (:cov-low-watermark opts)) diff --git a/test/unit/kaocha/plugin/cloverage_test.clj b/test/unit/kaocha/plugin/cloverage_test.clj index ea6967a..163c745 100644 --- a/test/unit/kaocha/plugin/cloverage_test.clj +++ b/test/unit/kaocha/plugin/cloverage_test.clj @@ -103,6 +103,18 @@ (is (match? {:fail-threshold 42} (update-config' {:fail-threshold 20} ["--cov-fail-threshold" "42"]))) (is (match? {:fail-threshold 42} (update-config' {} ["--cov-fail-threshold" "42"])))) + (testing "--cov-line-fail-threshold PERCENT" + (is (match? {:line-fail-threshold 0} (update-config' {} []))) + (is (match? {:line-fail-threshold 20} (update-config' {:line-fail-threshold 20} []))) + (is (match? {:line-fail-threshold 42} (update-config' {:line-fail-threshold 20} ["--cov-line-fail-threshold" "42"]))) + (is (match? {:line-fail-threshold 42} (update-config' {} ["--cov-line-fail-threshold" "42"])))) + + (testing "--cov-form-fail-threshold PERCENT" + (is (match? {:form-fail-threshold 0} (update-config' {} []))) + (is (match? {:form-fail-threshold 20} (update-config' {:form-fail-threshold 20} []))) + (is (match? {:form-fail-threshold 42} (update-config' {:form-fail-threshold 20} ["--cov-form-fail-threshold" "42"]))) + (is (match? {:form-fail-threshold 42} (update-config' {} ["--cov-form-fail-threshold" "42"])))) + (testing "--cov-low-watermark PERCENT" (is (match? {:low-watermark 50} (update-config' {} []))) (is (match? {:low-watermark 20} (update-config' {:low-watermark 20} [])))