Brian,

I don't blame you -- I wouldn't want to put conditional requires in my
code either.  Did you consider putting your mock code in a different
classpath?

Here is another idea.  It's tempting to suggest that you write your
own version of ns that mucks with its arguments and then passes the
results to the real ns.  Unfortunately, ns is a macro, so that's
probably a non-starter.  However, I think you could do something
similar with clojure.core/require.  Something like this:

(ns mocker)
(def orig-require clojure.core/require)

(ns clojure.core)
(defn require [& args] (println "this is require, args are" args)
(mocker/orig-require args))

Now when you load a namespace, any require clauses are intercepted by
your custom version of require first:

(ns blah (:require (tango.test initdb)))

Of course the custom require shown above just prints its arguments,
but you could imagine it consulting another function, or a map or
something, to determine when to swap out a library for its mock
version.  Would that fly?

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to