diff options
| author | Mike Hinchey <hincheymg@gmail.com> | 2009-07-13 13:54:24 -0700 |
|---|---|---|
| committer | Chouser <chouser@n01se.net> | 2009-08-19 22:40:16 -0400 |
| commit | abca86ea023080fd4ceed24b9887a653a56722eb (patch) | |
| tree | 91a7e3e3ea7959deb3ed9a7b8a0349185a0e5c42 /test | |
| parent | 16af3b1d04db6978d552b4440690d00a9e64a423 (diff) | |
fix #168, ant targets should fail on error, also test print report correctly
Signed-off-by: Chouser <chouser@n01se.net>
Diffstat (limited to 'test')
| -rw-r--r-- | test/clojure/test_clojure.clj | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/test/clojure/test_clojure.clj b/test/clojure/test_clojure.clj index 8b1e16ae..ac264e0f 100644 --- a/test/clojure/test_clojure.clj +++ b/test/clojure/test_clojure.clj @@ -15,7 +15,7 @@ ;; Created 22 October 2008 (ns clojure.test-clojure - (:use [clojure.test :only (run-tests)]) + (:require [clojure.test :as t]) (:gen-class)) (def test-names @@ -59,7 +59,23 @@ [] (println "Loading tests...") (apply require :reload-all test-namespaces) - (apply run-tests test-namespaces)) + (apply t/run-tests test-namespaces)) + +(defn run-ant + "Runs all defined tests, prints report to *err*, throw if failures. This works well for running in an ant java task." + [] + (let [rpt t/report] + (binding [;; binding to *err* because, in ant, when the test target + ;; runs after compile-clojure, *out* doesn't print anything + *out* *err* + t/*test-out* *err* + t/report (fn report [m] + (if (= :summary (:type m)) + (do (rpt m) + (if (or (pos? (:fail m)) (pos? (:error m))) + (throw (new Exception (str (:fail m) " failures, " (:error m) " errors."))))) + (rpt m)))] + (run)))) (defn -main "Run all defined tests from the command line" |
