Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't warn if side-effecting main hook returns nil #452

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
## Fixed

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

## Changed

Expand Down
10 changes: 4 additions & 6 deletions doc/09_extending.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,11 @@ The [hooks chapter](10_hooks.md) has more information about most of these hooks.
;; Runs right before kaocha.runner calls kaocha.api/run. This is for plugins
;; that optionally do something else besides running tests, like printing
;; informational messages and then exiting. For this throw+ a
;; {:kaocha/early-exit}.
;; {:kaocha/early-exit}. Ignores return value.
(main [config]
(if (:do-other-thing (:kaocha/cli-options config))
(do
(... do other thing ...)
(throw+ {:kaocha/early-exit 0}))
config))
(when (:do-other-thing (:kaocha/cli-options config))
(... do other thing ...)
(throw+ {:kaocha/early-exit 0})))

;; Gets called after the run is finished and the summary has been printed/reported.
;; Gets passed the test result map (test plan with results).
Expand Down
5 changes: 3 additions & 2 deletions src/kaocha/plugin.clj
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@
(reduce (fn [value plugin]
(if-let [step-fn (get plugin step)]
(let [value (apply step-fn value extra-args)]
(when (nil? value)
(output/warn "Plugin " (:kaocha.plugin/id plugin) " hook " step " returned nil."))
(when-not (= :kaocha.hooks/main step) ;; side-effects only
(when (nil? value)
(output/warn "Plugin " (:kaocha.plugin/id plugin) " hook " step " returned nil.")))
value)
value))
value
Expand Down
Loading