Skip to content

Commit

Permalink
Release 1.0.3 adds requires / shutdown options.
Browse files Browse the repository at this point in the history
This allows you to run post-test cleanup inside the pod.
  • Loading branch information
seancorfield committed Dec 25, 2015
1 parent f834a56 commit 837665f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

[](dependency)
```clojure
[seancorfield/boot-expectations "1.0.2"] ;; latest release
[seancorfield/boot-expectations "1.0.3"] ;; latest release
```
[](/dependency)

Expand Down Expand Up @@ -51,6 +51,7 @@ boot watch speak expectations

## Changes

1.0.3 - 12/25/2015 - Add `--requires` / `--shutdown` options.
1.0.2 - 12/24/2015 - Create pod before task body for efficiency.
1.0.1 - 12/20/2015 - Add `distinct` to dedupe list of namespaces (#7).
1.0.0 - 12/19/2015 - Initial public release.
Expand Down
2 changes: 1 addition & 1 deletion build.boot
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(set-env!
:resource-paths #{"src"})

(def version "1.0.2")
(def version "1.0.3")

(task-options!
pom {:project 'seancorfield/boot-expectations
Expand Down
32 changes: 20 additions & 12 deletions src/seancorfield/boot_expectations.clj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
'[[expectations "2.1.4"]
[org.clojure/tools.namespace "0.2.11"]]))

(defn init [fresh-pod]
(defn init [requires fresh-pod]
(doseq [r '[[clojure.java.io :as io]
[clojure.tools.namespace.find :as f]]]
(pod/require-in fresh-pod r)))
Expand All @@ -28,19 +28,23 @@
will be used.
You can specify regular expressions for namespaces to include and exclude."
[c clojure VERSION str "the version of Clojure for testing."
e exclude REGEX regex "the filter for excluded namespaces"
i include REGEX regex "the filter for included namespaces"
v verbose bool "Display each namespace completed"]
(let [pod-deps (update-in (core/get-env) [:dependencies]
[c clojure VERSION str "the version of Clojure for testing."
e exclude REGEX regex "the filter for excluded namespaces"
i include REGEX regex "the filter for included namespaces"
r requires NS #{sym} "namespaces to be required at pod startup"
s shutdown FN #{sym} "functions to be called prior to pod shutdown"
v verbose bool "Display each namespace completed"]
(let [exclude (or exclude #"^$")
include (or include #".*")
requires (or requires #{})
shutdown (or shutdown #{})
pod-deps (update-in (core/get-env) [:dependencies]
(fn [deps]
(cond->> (into deps (pod-deps))
clojure (mapv (partial replace-clojure-version clojure)))))
pods (pod/pod-pool pod-deps :init init)]
pods (pod/pod-pool pod-deps :init (partial init requires))]
(core/with-pass-thru [fs]
(let [dirs (mapv (memfn getPath) (core/input-dirs fs))
include (or include #".*")
exclude (or exclude #"^$")]
(let [dirs (mapv (memfn getPath) (core/input-dirs fs))]
(core/cleanup (pods :shutdown))
(let [{:keys [fail error] :as summary}
(pod/with-eval-in (pods :refresh)
Expand All @@ -50,7 +54,11 @@
:when (and (re-find ~include (name n))
(not (re-find ~exclude (name n))))]
(require n))
(binding [e/ns-finished (if ~verbose (fn [ns] (println "\nCompleted" ns)) (constantly nil))]
(e/run-all-tests)))]
(try
(binding [e/ns-finished (if ~verbose (fn [ns] (println "\nCompleted" ns)) (constantly nil))]
(e/run-all-tests))
(finally
(doseq [f ~shutdown]
(f)))))]
(when (pos? (+ fail error))
(throw (ex-info "Some tests failed or errored" summary))))))))

0 comments on commit 837665f

Please sign in to comment.