Permalink
Browse files

Only run test namespaces that match a test selector

  • Loading branch information...
1 parent b4c5fe5 commit 8b3fb9e494c30206854b85518146c7e8195507b1 @balinterdi balinterdi committed Nov 30, 2012
Showing with 16 additions and 3 deletions.
  1. +16 −3 src/leiningen/test.clj
View
@@ -45,7 +45,20 @@
(println "\nlein test" (ns-name (:ns m#))))
(apply report# m# args#))))
summary# (binding [clojure.test/*test-out* *out*]
- (apply ~'clojure.test/run-tests '~namespaces))]
+ (apply ~'clojure.test/run-tests
+ ~(if (seq selectors)
+ `(distinct
+ (for [ns# '~namespaces
+ [_# var#] (ns-publics ns#)
+ :when (reduce (fn [acc# [selector# args#]]
+ (or acc#
+ (apply selector#
+ (merge (-> var# meta :ns meta)
+ (assoc (meta var#) ::var var#))
+ args#)))
+ false ~selectors)]
+ ns#))
+ 'namespaces)))]
(spit ".lein-failures" (pr-str @failures#))
(when ~*exit-after-tests*
(System/exit (+ (:error summary#) (:fail summary#))))))))
@@ -82,12 +95,12 @@
selectors (partial-selectors (merge {:all '(constantly true)}
{:only only-form}
(:test-selectors project))
- given-selectors)
+ given-selectors)
selectors (if (and (empty? selectors)
(:default (:test-selectors project)))
[[(:default (:test-selectors project)) ()]]
selectors)]
- (when (and (empty? selectors)
+ (when (and (empty? selectors)
(seq given-selectors))
(main/abort "Please specify :test-selectors in project.clj"))
[nses selectors]))

0 comments on commit 8b3fb9e

Please sign in to comment.