Skip to content

Commit

Permalink
test-load-all tries to load all nondeprecated namespaces
Browse files Browse the repository at this point in the history
 - fixed bug: misspelling in pom
 - updated gen-html-docs to track c.c.string name changes
  • Loading branch information
stuarthalloway committed Apr 13, 2010
1 parent b9db280 commit b52f0b6
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 97 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -93,7 +93,7 @@
<namespaces>
<namespace>clojure\.contrib\.jmx\.Bean</namespace>
<namespace>clojure\.contrib\.fnmap\.PersistentFnMap</namespace>
<namespace>clojure\.contrib\.conditition\.Condition</namespace>
<namespace>clojure\.contrib\.condition\.Condition</namespace>
<namespace>clojure\.contrib\.repl-ln</namespace>
<namespace>clojure\.contrib\.pprint\.gen-class</namespace>
</namespaces>
Expand Down
11 changes: 6 additions & 5 deletions src/main/clojure/clojure/contrib/gen_html_docs.clj
Expand Up @@ -46,8 +46,9 @@
:doc "Generates a single HTML page that contains the documentation for
one or more Clojure libraries."}
clojure.contrib.gen-html-docs
(:require [clojure.contrib.io :as io])
(:use [clojure.contrib seq string repl-utils def prxml])
(:require [clojure.contrib.io :as io]
[clojure.contrib.string :as s])
(:use [clojure.contrib seq repl-utils def prxml])
(:import [java.lang Exception]
[java.util.regex Pattern]))

Expand Down Expand Up @@ -226,7 +227,7 @@ function toggle(targetid, linkid, textWhenOpen, textWhenClosed)
(if (= 0 (count l))
[:span {:class "library-member-doc-whitespace"} " "] ; We need something here to make the blank line show up
l)])
(re-split #"\n" docs))
(s/split #"\n" docs))
""))

(defn- member-type
Expand Down Expand Up @@ -270,7 +271,7 @@ function toggle(targetid, linkid, textWhenOpen, textWhenClosed)
(defn- elide-to-one-line
"Elides a string down to one line."
[s]
(re-sub #"(\n.*)+" "..." s))
(s/replace-re #"(\n.*)+" "..." s))

(defn- elide-string
"Returns a string that is at most the first limit characters of s"
Expand All @@ -282,7 +283,7 @@ function toggle(targetid, linkid, textWhenOpen, textWhenClosed)
(defn- doc-elided-src
"Returns the src with the docs elided."
[docs src]
(re-sub (re-pattern (str "\"" (Pattern/quote docs) "\""))
(s/replace-re (re-pattern (str "\"" (Pattern/quote docs) "\""))
(str "\""
(elide-to-one-line docs)
;; (elide-string docs 10)
Expand Down
91 changes: 0 additions & 91 deletions src/main/clojure/clojure/contrib/load_all.clj

This file was deleted.

53 changes: 53 additions & 0 deletions src/test/clojure/clojure/contrib/test_load_all.clj
@@ -0,0 +1,53 @@
;;; test_load_all.clj - loads all contrib libraries for testing purposes

;; by Stuart Halloway, http://blog.thinkrelevance.com

;; Copyright (c) Stuart Halloway, 2009. All rights reserved. The use
;; and distribution terms for this software are covered by the Eclipse
;; Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
;; which can be found in the file epl-v10.html at the root of this
;; distribution. By using this software in any fashion, you are
;; agreeing to be bound by the terms of this license. You must not
;; remove this notice, or any other, from this software.

;; This is only intended to check that the libraries will load without
;; errors, not that they work correctly.

;; The code includes several design choices I don't love, but find
;; tolerable in a test-only lib:
;;
;; * namespaces that blow up to document deprecation
;; * using directory paths to find contrib
;; * using a macro to reflectively write tests
;;
;; I *am* happy that code that won't even load now breaks the build.

(ns clojure.contrib.test-load-all
(:use clojure.test clojure.contrib.find-namespaces))

(def deprecated-contrib-namespaces
'[clojure.contrib.javadoc])

(defn loadable-contrib-namespaces
"Contrib namespaces that can be loaded (everything except
deprecated nses that throw on load.)"
[]
(apply disj
(into #{} (find-namespaces-in-dir (java.io.File. "src/main")))
deprecated-contrib-namespaces))

(defn emit-test-load
[]
`(do
~@(map
(fn [ns]
`(deftest ~(symbol (str "test-loading-" (.replace (str ns) "." "-")))
(require :reload '~ns)))
(loadable-contrib-namespaces))))

(defmacro test-load
[]
(emit-test-load))

(test-load)

0 comments on commit b52f0b6

Please sign in to comment.