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 | |
parent | 16af3b1d04db6978d552b4440690d00a9e64a423 (diff) |
fix #168, ant targets should fail on error, also test print report correctly
Signed-off-by: Chouser <chouser@n01se.net>
-rw-r--r-- | build.xml | 7 | ||||
-rw-r--r-- | test/clojure/test_clojure.clj | 20 |
2 files changed, 22 insertions, 5 deletions
@@ -85,7 +85,8 @@ <target name="compile-clojure" depends="compile-java" description="Compile Clojure sources."> <java classname="clojure.lang.Compile" - classpath="${build}:${cljsrc}"> + classpath="${build}:${cljsrc}" + failonerror="true"> <sysproperty key="clojure.compile.path" value="${build}"/> <arg value="clojure.core"/> <arg value="clojure.main"/> @@ -119,13 +120,13 @@ <target name="test" description="Run clojure tests"> <!-- depends="clojure"> --> - <java classname="clojure.main"> + <java classname="clojure.main" failonerror="true"> <classpath> <path location="${test}"/> <path location="${clojure_jar}"/> </classpath> <arg value="-e"/> - <arg value="(require '(clojure [test-clojure :as main])) (main/run)"/> + <arg value="(require '(clojure [test-clojure :as main])) (main/run-ant)"/> </java> </target> 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" |