Added test namespace/task.
This commit is contained in:
parent
a96d05e4d1
commit
73115a5765
2 changed files with 29 additions and 0 deletions
|
@ -12,6 +12,8 @@ Leiningen is a build tool for Clojure designed to not set your hair on fire.
|
|||
|
||||
$ lein deps # install dependencies in lib/
|
||||
|
||||
$ lein test [PRED] # run the project's tests, optionally filtered on PRED
|
||||
|
||||
$ lein compile # ahead-of-time compile into classes/
|
||||
|
||||
$ lein repl # launch a REPL with the project classpath configured
|
||||
|
|
27
src/leiningen/test.clj
Normal file
27
src/leiningen/test.clj
Normal file
|
@ -0,0 +1,27 @@
|
|||
(ns leiningen.test
|
||||
(:refer-clojure :exclude [test])
|
||||
(:use [clojure.test]
|
||||
[clojure.contrib.java-utils :only [file]]
|
||||
[clojure.contrib.find-namespaces :only [find-namespaces-in-dir]]))
|
||||
|
||||
(defonce old-test-var test-var)
|
||||
|
||||
(defn test-var-matching [pred var]
|
||||
(when (pred (meta var))
|
||||
(old-test-var var)))
|
||||
|
||||
(defn run-matching [pred namespaces]
|
||||
(binding [test-var (partial test-var-matching pred)]
|
||||
(apply run-tests namespaces)))
|
||||
|
||||
(defn test
|
||||
"Run the projects tests. Second argument is an optional filter predicate that
|
||||
is called with each test's metadata map."
|
||||
[project & [pred]]
|
||||
(let [namespaces (find-namespaces-in-dir (file (:root project) "test"))
|
||||
runner (if pred
|
||||
(partial run-matching (eval pred))
|
||||
run-tests)]
|
||||
(doseq [n namespaces]
|
||||
(require n))
|
||||
(apply runner namespaces)))
|
Loading…
Reference in a new issue