Skip to content

Commit 26453a6

Browse files
committed
Don't warn if side-effecting main hook returns nil
1 parent 15e553d commit 26453a6

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
## Fixed
66

77
- Fix beholder watch functionality that would cause a NullPointerException earlier.
8+
- Don't warn if side-effecting `main` hook returns nil.
89

910
## Changed
1011

doc/09_extending.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,11 @@ The [hooks chapter](10_hooks.md) has more information about most of these hooks.
191191
;; Runs right before kaocha.runner calls kaocha.api/run. This is for plugins
192192
;; that optionally do something else besides running tests, like printing
193193
;; informational messages and then exiting. For this throw+ a
194-
;; {:kaocha/early-exit}.
194+
;; {:kaocha/early-exit}. Ignores return value.
195195
(main [config]
196-
(if (:do-other-thing (:kaocha/cli-options config))
197-
(do
198-
(... do other thing ...)
199-
(throw+ {:kaocha/early-exit 0}))
200-
config))
196+
(when (:do-other-thing (:kaocha/cli-options config))
197+
(... do other thing ...)
198+
(throw+ {:kaocha/early-exit 0})))
201199

202200
;; Gets called after the run is finished and the summary has been printed/reported.
203201
;; Gets passed the test result map (test plan with results).

src/kaocha/plugin.clj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,9 @@
8989
(reduce (fn [value plugin]
9090
(if-let [step-fn (get plugin step)]
9191
(let [value (apply step-fn value extra-args)]
92-
(when (nil? value)
93-
(output/warn "Plugin " (:kaocha.plugin/id plugin) " hook " step " returned nil."))
92+
(when-not (= :kaocha.hooks/main step) ;; side-effects only
93+
(when (nil? value)
94+
(output/warn "Plugin " (:kaocha.plugin/id plugin) " hook " step " returned nil.")))
9495
value)
9596
value))
9697
value

0 commit comments

Comments
 (0)