So I thought I'd see if I could use tests in source code and add a
hook to lein to bind *load-tests* to false around the compile but I'm
missing something...

Here's my hook:

(ns leiningen.notests)

(use 'robert.hooke)

(defn no-tests [task & args]
  (binding [clojure.test/*load-tests* false]
    (apply task args)))

(add-hook #'leiningen.compile/compile no-tests)

I've added this to my project.clj:

  :dev-dependencies [[robert/hooke "1.0.2"]]
  :hooks [leiningen.notests]

lein happily pulled down the library and tries to run the hook but I get:

Warning: problem requiring hooks: java.lang.Exception: Unable to
resolve var: clojure.test/*load-tests* in this context (notests.clj:6)

Fair enough, I thought, maybe I need to require or use clojure.test in
the hook. I added (use 'clojure.test) and got this error:

Warning: problem requiring hooks: java.lang.NoClassDefFoundError:
Could not initialize class clojure.test__init (notests.clj:1)

I've tried (:use [clojure.test]) in the (ns) and (:require
[clojure.test]) but I still hit this error.

What am I missing?

(I'm still struggling with the build / dependency aspect of this stuff)

Thanx,
Sean

On Sun, Aug 29, 2010 at 2:57 PM, Sean Corfield <seancorfi...@gmail.com> wrote:
> Thanx Stuart. I had a feeling it might require that. I've mostly been
> using lein and keeping the tests separate but when I saw that in the
> docs I thought I'd try it because it would be kinda convenient inside
> CCW / Eclipse while developing.
>
> On Sunday, August 29, 2010, Stuart Sierra <the.stuart.sie...@gmail.com> wrote:
>> Hi Sean,
>>
>> As far as I know, that feature never saw much use. Most people like to
>> keep their test and main sources separate, and build tools assume
>> this.
>>
>> To bind *load-tests* during compilation, you would need to control
>> your own build process. Basically, you would have to launch Clojure
>> and execute a script that binds *load-tess* and then calls "compile"
>> by hand. I don't think this is possible with Leiningen or Maven, but
>> you could do it with Ant. I doubt it's worth the trouble.
>>
>> -S
>>

-- 
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