view src/clojure/contrib/test_contrib/test_load_all.clj @ 10:ef7dbbd6452c

added clojure source goodness
author Robert McIntyre <rlm@mit.edu>
date Sat, 21 Aug 2010 06:25:44 -0400
parents
children
line wrap: on
line source
1 ;;; test_load_all.clj - loads all contrib libraries for testing purposes
3 ;; by Stuart Halloway, http://blog.thinkrelevance.com
5 ;; Copyright (c) Stuart Halloway, 2009. All rights reserved. The use
6 ;; and distribution terms for this software are covered by the Eclipse
7 ;; Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
8 ;; which can be found in the file epl-v10.html at the root of this
9 ;; distribution. By using this software in any fashion, you are
10 ;; agreeing to be bound by the terms of this license. You must not
11 ;; remove this notice, or any other, from this software.
13 ;; This is only intended to check that the libraries will load without
14 ;; errors, not that they work correctly.
16 ;; The code includes several design choices I don't love, but find
17 ;; tolerable in a test-only lib:
18 ;;
19 ;; * namespaces that blow up to document deprecation
20 ;; * using directory paths to find contrib
21 ;; * using a macro to reflectively write tests
22 ;;
23 ;; I *am* happy that code that won't even load now breaks the build.
25 (ns clojure.contrib.test-load-all
26 (:use clojure.test clojure.contrib.find-namespaces))
28 (def deprecated-contrib-namespaces
29 '[clojure.contrib.javadoc])
31 (defn loadable-contrib-namespaces
32 "Contrib namespaces that can be loaded (everything except
33 deprecated nses that throw on load.)"
34 []
35 (apply disj
36 (into #{} (find-namespaces-in-dir (java.io.File. "src/main")))
37 deprecated-contrib-namespaces))
39 (defn emit-test-load
40 []
41 `(do
42 ~@(map
43 (fn [ns]
44 `(deftest ~(symbol (str "test-loading-" (.replace (str ns) "." "-")))
45 (require :reload '~ns)))
46 (loadable-contrib-namespaces))))
48 (defmacro test-load
49 []
50 (emit-test-load))
52 (test-load)