annotate src/clojure/test_clojure.clj @ 10:ef7dbbd6452c

added clojure source goodness
author Robert McIntyre <rlm@mit.edu>
date Sat, 21 Aug 2010 06:25:44 -0400
parents
children
rev   line source
rlm@10 1 ; Copyright (c) Rich Hickey. All rights reserved.
rlm@10 2 ; The use and distribution terms for this software are covered by the
rlm@10 3 ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
rlm@10 4 ; which can be found in the file epl-v10.html at the root of this distribution.
rlm@10 5 ; By using this software in any fashion, you are agreeing to be bound by
rlm@10 6 ; the terms of this license.
rlm@10 7 ; You must not remove this notice, or any other, from this software.
rlm@10 8 ;
rlm@10 9
rlm@10 10 ;; clojure.test-clojure
rlm@10 11 ;;
rlm@10 12 ;; Tests for the facilities provided by Clojure
rlm@10 13 ;;
rlm@10 14 ;; scgilardi (gmail)
rlm@10 15 ;; Created 22 October 2008
rlm@10 16
rlm@10 17 (ns clojure.test-clojure
rlm@10 18 (:require [clojure.test :as t])
rlm@10 19 (:gen-class))
rlm@10 20
rlm@10 21 (def test-names
rlm@10 22 [:reader
rlm@10 23 :printer
rlm@10 24 :compilation
rlm@10 25 :evaluation
rlm@10 26 :special
rlm@10 27 :macros
rlm@10 28 :metadata
rlm@10 29 :ns-libs
rlm@10 30 :logic
rlm@10 31 :predicates
rlm@10 32 :control
rlm@10 33 :data-structures
rlm@10 34 :numbers
rlm@10 35 :sequences
rlm@10 36 :for
rlm@10 37 :multimethods
rlm@10 38 :other-functions
rlm@10 39 :vars
rlm@10 40 :refs
rlm@10 41 :agents
rlm@10 42 :atoms
rlm@10 43 :parallel
rlm@10 44 :java-interop
rlm@10 45 :test
rlm@10 46 :test-fixtures
rlm@10 47 ;; libraries
rlm@10 48 :clojure-set
rlm@10 49 :clojure-xml
rlm@10 50 :clojure-zip
rlm@10 51 :protocols
rlm@10 52 :genclass
rlm@10 53 :main
rlm@10 54 :vectors
rlm@10 55 :annotations
rlm@10 56 :pprint
rlm@10 57 :serialization
rlm@10 58 :rt
rlm@10 59 :repl
rlm@10 60 :java.io
rlm@10 61 :string
rlm@10 62 :java.javadoc
rlm@10 63 :java.shell
rlm@10 64 :transients
rlm@10 65 :def
rlm@10 66 ])
rlm@10 67
rlm@10 68 (def test-namespaces
rlm@10 69 (map #(symbol (str "clojure.test-clojure." (name %)))
rlm@10 70 test-names))
rlm@10 71
rlm@10 72 (defn run
rlm@10 73 "Runs all defined tests"
rlm@10 74 []
rlm@10 75 (println "Loading tests...")
rlm@10 76 (apply require :reload-all test-namespaces)
rlm@10 77 (apply t/run-tests test-namespaces))
rlm@10 78
rlm@10 79 (defn run-ant
rlm@10 80 "Runs all defined tests, prints report to *err*, throw if failures. This works well for running in an ant java task."
rlm@10 81 []
rlm@10 82 (let [rpt t/report]
rlm@10 83 (binding [;; binding to *err* because, in ant, when the test target
rlm@10 84 ;; runs after compile-clojure, *out* doesn't print anything
rlm@10 85 *out* *err*
rlm@10 86 t/*test-out* *err*
rlm@10 87 t/report (fn report [m]
rlm@10 88 (if (= :summary (:type m))
rlm@10 89 (do (rpt m)
rlm@10 90 (if (or (pos? (:fail m)) (pos? (:error m)))
rlm@10 91 (throw (new Exception (str (:fail m) " failures, " (:error m) " errors.")))))
rlm@10 92 (rpt m)))]
rlm@10 93 (run))))
rlm@10 94
rlm@10 95 (defn -main
rlm@10 96 "Run all defined tests from the command line"
rlm@10 97 [& args]
rlm@10 98 (run)
rlm@10 99 (System/exit 0))