Permalink
Browse files

CLJ-1352: Don't run :each fixtures for vars with no :test metadata

This includes a regression test, and fixes the :added meta for
test-vars to be 1.6.

Signed-off-by: Stuart Halloway <stu@cognitect.com>
  • Loading branch information...
1 parent 2df9ace commit 919a7100ddf327d73bc2d50d9ee1411d4a0e8921 @tobias tobias committed with stuarthalloway Feb 15, 2014
Showing with 10 additions and 3 deletions.
  1. +3 −2 src/clj/clojure/test.clj
  2. +7 −1 test/clojure/test_clojure/test_fixtures.clj
View
@@ -710,15 +710,16 @@
(defn test-vars
"Groups vars by their namespace and runs test-vars on them with
appropriate fixtures applied."
- {:added "1.5"}
+ {:added "1.6"}
[vars]
(doseq [[ns vars] (group-by (comp :ns meta) vars)]
(let [once-fixture-fn (join-fixtures (::once-fixtures (meta ns)))
each-fixture-fn (join-fixtures (::each-fixtures (meta ns)))]
(once-fixture-fn
(fn []
(doseq [v vars]
- (each-fixture-fn (fn [] (test-var v)))))))))
+ (when (:test (meta v))
+ (each-fixture-fn (fn [] (test-var v))))))))))
(defn test-all-vars
"Calls test-vars on every var interned in the namespace, with fixtures."
@@ -59,9 +59,15 @@
;; running, in order to distinguish fixtures run because of our call to
;; test-vars below from the same fixtures running prior to this test
(let [side-effects-so-far @side-effects
-
reported (atom [])]
(binding [report (fn [m] (swap! reported conj (:type m)))]
(test-vars [#'can-use-each-fixtures]))
(is (= [:begin-test-var :pass :pass :end-test-var] @reported))
(is (= (inc side-effects-so-far) @side-effects))))
+
+(defn should-not-trigger-fixtures [])
+
+(deftest a-var-lacking-test-meta-should-not-trigger-fixtures
+ (let [side-effects-so-far @side-effects]
+ (test-vars [#'should-not-trigger-fixtures])
+ (is (= side-effects-so-far @side-effects))))

0 comments on commit 919a710

Please sign in to comment.