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