Skip to content

Commit

Permalink
change mute-zero-assertions to warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurence Chen committed Apr 5, 2023
1 parent 87a30e8 commit c178ed0
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 13 deletions.
1 change: 0 additions & 1 deletion doc/03_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Here's an example test configuration with a single test suite:
:kaocha/source-paths ["src"]
:kaocha/test-paths ["test/unit"]}]
:kaocha/fail-fast? false
:kaocha/mute-zero-assertion? true
:kaocha/color? true
:kaocha/reporter [kaocha.report/dots]
:kaocha/plugins [:kaocha.plugin/randomize
Expand Down
4 changes: 1 addition & 3 deletions doc/clojure_test/assertions.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ Test ran without assertions. Did you forget an (is ...)?

There are two ways to disable this detection:

* Enable `:mute-zero-assertion?` at `tests.edn`.
* Use `--mute-zero-assertion` in command line argument.

* Add `:kaocha/warnings {:zero-assertions :silent}` into `tests.edn`.

## Detecting single argument `=`

Expand Down
4 changes: 2 additions & 2 deletions src/kaocha/api.clj
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
(let [config (plugin/run-hook :kaocha.hooks/config config)
color? (:kaocha/color? config)
fail-fast? (:kaocha/fail-fast? config)
mute-zero-assertion? (:kaocha/mute-zero-assertion? config)
warnings (:kaocha/warnings config)
history (atom [])]
(binding [*active?* true
testable/*fail-fast?* fail-fast?
Expand All @@ -103,7 +103,7 @@
(let [config (resolve-reporter config)]
(let [test-plan (test-plan config)]

(when mute-zero-assertion?
(when (= (:zero-assertions warnings) :silent)
(hierarchy/underive! :kaocha.type.var/zero-assertions :kaocha/known-key)
(hierarchy/underive! :kaocha.type.var/zero-assertions :kaocha/fail-type))

Expand Down
7 changes: 3 additions & 4 deletions src/kaocha/config.clj
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
reporter
color?
fail-fast?
mute-zero-assertion?
warnings
diff-style
randomize?
capture-output?
Expand All @@ -89,15 +89,15 @@
tests (assoc :kaocha/tests (vary-meta tests assoc :replace true))
plugins (assoc :kaocha/plugins plugins)
reporter (assoc :kaocha/reporter (vary-meta reporter assoc :replace true))
warnings (assoc :kaocha/warnings warnings)
bindings (assoc :kaocha/bindings bindings)
(some? color?) (assoc :kaocha/color? color?)
(some? fail-fast?) (assoc :kaocha/fail-fast? fail-fast?)
(some? mute-zero-assertion?) (assoc :kaocha/mute-zero-assertion? mute-zero-assertion?)
(some? diff-style) (assoc :kaocha/diff-style diff-style)
(some? watch?) (assoc :kaocha/watch? watch?)
(some? randomize?) (assoc :kaocha.plugin.randomize/randomize? randomize?)
(some? capture-output?) (assoc :kaocha.plugin.capture-output/capture-output? capture-output?)
:-> (merge (dissoc config :tests :plugins :reporter :color? :fail-fast? :mute-zero-assertion? :watch? :randomize?)))))
:-> (merge (dissoc config :tests :plugins :reporter :warnings :color? :fail-fast? :watch? :randomize?)))))

(defmethod aero/reader 'kaocha [_opts _tag value]
(output/warn (format "The #kaocha reader literal is deprecated, please change it to %s." current-reader))
Expand Down Expand Up @@ -200,7 +200,6 @@
(defn apply-cli-opts [config options]
(cond-> config
(some? (:fail-fast options)) (assoc :kaocha/fail-fast? (:fail-fast options))
(some? (:mute-zero-assertion options)) (assoc :kaocha/mute-zero-assertion? (:mute-zero-assertion options))
(:reporter options) (assoc :kaocha/reporter (:reporter options))
(:watch options) (assoc :kaocha/watch? (:watch options))
(some? (:color options)) (assoc :kaocha/color? (:color options))
Expand Down
1 change: 0 additions & 1 deletion src/kaocha/runner.clj
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
[nil "--print-test-plan" "Load tests, build up a test plan, then print out the test plan and exit."]
[nil "--print-result" "Print the test result map as returned by the Kaocha API."]
[nil "--[no-]fail-fast" "Stop testing after the first failure."]
[nil "--[no-]mute-zero-assertion" "Stop raising failure when there is no assertion in test."]
[nil "--[no-]color" "Enable/disable ANSI color codes in output. Defaults to true."]
[nil "--[no-]watch" "Watch filesystem for changes and re-run tests."]
[nil "--reporter SYMBOL" "Change the test reporter, can be specified multiple times."
Expand Down
4 changes: 2 additions & 2 deletions src/kaocha/specs.clj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

(spec/def :kaocha/fail-fast? boolean?)

(spec/def :kaocha/mute-zero-assertion? boolean?)
(spec/def :kaocha/warnings (spec/map-of #{:zero-assertions} #{:silent :error}))

(spec/def :kaocha/watch? boolean?)

Expand All @@ -36,7 +36,7 @@
(spec/keys :opt [:kaocha/reporter
:kaocha/color?
:kaocha/fail-fast?
:kaocha/mute-zero-assertion?
:kaocha/warnings
:kaocha/watch?
:kaocha/plugins]))

Expand Down

0 comments on commit c178ed0

Please sign in to comment.