Skip to content

Commit

Permalink
Merge pull request #15 from ducky427/run-once-fixture-only-if-needed
Browse files Browse the repository at this point in the history
Only run once fixture if we actually run any tests in a ns
  • Loading branch information
technomancy committed Sep 8, 2017
2 parents d0c9cfa + e9b85da commit 9125916
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/circleci/test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,14 @@
(test-var* config v))))


(defn- get-all-vars [config ns selector]
(for [v (vals (ns-interns ns))
:when (and (:test (meta v)) (selector (meta v)))]
v))

(defn- test-all-vars [config ns selector]
(doseq [v (vals (ns-interns ns))]
(when (and (:test (meta v)) (selector (meta v)))
(test-var v config))))
(doseq [v (get-all-vars config ns selector)]
(test-var v config)))

(defn test-ns
"The entry-poing into circleci.test for running all tests in a namespace.
Expand All @@ -141,8 +145,11 @@
test/report report/report
report/*reporters* (get-reporters config)]
(let [ns-obj (the-ns ns)
run-once-fixture? (seq (get-all-vars config ns selector))
global-fixture-fn (make-global-fixture config)
once-fixture-fn (once-fixtures ns-obj)]
once-fixture-fn (if run-once-fixture?
(once-fixtures ns-obj)
(fn [f] ((make-once-fixture-fn ns) f)))]
(global-fixture-fn
(fn []
(once-fixture-fn
Expand Down

0 comments on commit 9125916

Please sign in to comment.