Prevent users of Clojure 1.0 from calling the test task and point them

to the lein-test-is plugin. closes #21
This commit is contained in:
abscondment 2010-03-05 15:18:37 -08:00 committed by Phil Hagelberg
parent 41fd7425ef
commit b19d46b6d0

View file

@ -9,20 +9,29 @@
"Return a form that when eval'd in the context of the project will test "Return a form that when eval'd in the context of the project will test
each namespace and print an overall summary." each namespace and print an overall summary."
[namespaces] [namespaces]
`(do (use ~''clojure.test) `(do
(let [add-numbers# (fn [a# b#] (if (number? a#) (require ~''clojure.test)
(if (and (= 1 (:major *clojure-version*))
(= 0 (:minor *clojure-version*)))
(println "\"lein test\" is not compatible with Clojure 1.0.\n
Please consider upgrading to a newer version of Clojure or using"
"the lein-test-is plugin.")
(let [resolver# (fn [fname#]
(ns-resolve
(find-ns 'clojure.test) fname#))
add-numbers# (fn [a# b#] (if (number? a#)
(+ a# b#) a#)) (+ a# b#) a#))
summary# (reduce (fn [summary# n#] summary# (reduce (fn [summary# n#]
(require n# :reload-all) (require n# :reload-all)
(merge-with add-numbers# (merge-with add-numbers#
summary# summary#
(clojure.test/run-tests n#))) ((resolver# ~''run-tests) n#)))
{} '~namespaces)] {} '~namespaces)]
(clojure.test/with-test-out ((resolver# ~''with-test-out)
(println "\n\n--------------------\nTotal:") (println "\n\n--------------------\nTotal:")
(clojure.test/report summary#)) ((resolver# ~''report) summary#))
(when-not (= "1.5" (System/getProperty "java.specification.version")) (when-not (= "1.5" (System/getProperty "java.specification.version"))
(shutdown-agents))))) (shutdown-agents))))))
(defn test (defn test
"Run the project's tests. Accept a list of namespaces for which to run all "Run the project's tests. Accept a list of namespaces for which to run all