Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #873 from balinterdi/only-run-tests-which-match-se…

…lector

Only run tests which match selector
  • Loading branch information...
commit 751b253f3040c8ec712f4c903580611f1aec1b6a 2 parents 8f46783 + c485365
@technomancy authored
Showing with 16 additions and 3 deletions.
  1. +16 −3 src/leiningen/test.clj
View
19 src/leiningen/test.clj
@@ -33,6 +33,19 @@
(apply require :reload '~namespaces))
~(form-for-hook-selectors selectors)
(let [failures# (atom #{})
+ selected-namespaces# ~(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)
_# (leiningen.core.injected/add-hook
#'clojure.test/report
(fn [report# m# & args#]
@@ -45,7 +58,7 @@
(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 selected-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]))
Please sign in to comment.
Something went wrong with that request. Please try again.