diff 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 diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/clojure/contrib/test_contrib/test_load_all.clj	Sat Aug 21 06:25:44 2010 -0400
     1.3 @@ -0,0 +1,53 @@
     1.4 +;;; test_load_all.clj - loads all contrib libraries for testing purposes
     1.5 +
     1.6 +;; by Stuart Halloway, http://blog.thinkrelevance.com
     1.7 +
     1.8 +;; Copyright (c) Stuart Halloway, 2009. All rights reserved.  The use
     1.9 +;; and distribution terms for this software are covered by the Eclipse
    1.10 +;; Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
    1.11 +;; which can be found in the file epl-v10.html at the root of this
    1.12 +;; distribution.  By using this software in any fashion, you are
    1.13 +;; agreeing to be bound by the terms of this license.  You must not
    1.14 +;; remove this notice, or any other, from this software.
    1.15 +
    1.16 +;; This is only intended to check that the libraries will load without
    1.17 +;; errors, not that they work correctly.
    1.18 +
    1.19 +;; The code includes several design choices I don't love, but find
    1.20 +;; tolerable in a test-only lib:
    1.21 +;; 
    1.22 +;;   * namespaces that blow up to document deprecation
    1.23 +;;   * using directory paths to find contrib
    1.24 +;;   * using a macro to reflectively write tests
    1.25 +;;
    1.26 +;; I *am* happy that code that won't even load now breaks the build.
    1.27 +
    1.28 +(ns clojure.contrib.test-load-all
    1.29 +  (:use clojure.test clojure.contrib.find-namespaces))
    1.30 +
    1.31 +(def deprecated-contrib-namespaces
    1.32 +  '[clojure.contrib.javadoc])
    1.33 +
    1.34 +(defn loadable-contrib-namespaces
    1.35 +  "Contrib namespaces that can be loaded (everything except
    1.36 +   deprecated nses that throw on load.)"
    1.37 +  []
    1.38 +  (apply disj
    1.39 +         (into #{} (find-namespaces-in-dir (java.io.File. "src/main")))
    1.40 +         deprecated-contrib-namespaces))
    1.41 +
    1.42 +(defn emit-test-load
    1.43 +  []
    1.44 +  `(do
    1.45 +     ~@(map
    1.46 +        (fn [ns]
    1.47 +          `(deftest ~(symbol (str "test-loading-" (.replace (str ns) "." "-")))
    1.48 +             (require :reload '~ns)))
    1.49 +        (loadable-contrib-namespaces))))
    1.50 +
    1.51 +(defmacro test-load
    1.52 +  []
    1.53 +  (emit-test-load))
    1.54 +
    1.55 +(test-load)
    1.56 +