tags:

views:

228

answers:

1

I'm trying to programatically load some clojure libraries to make a simple auto-test program.

What I end up sending to require is this

(require :reload '("peg" "test.peg-test"))

How do I transform that list into something useful, or am I totally barking up the wrong tree?

+3  A: 

Are you aware that there are testing libraries available in clojure.contrib?

You may find it easier to do this if you orient your thinking around namespaces. If you look at Bill Clementson's user.clj you will find a useful function for clearing out the user namespace and reloading the base namespaces in preparation for bringing in your testing namespaces.

In any case, using namespaces your code would work like this:

(ns testing-peg
  (:require [peg test.peg-test])
Pinochle
the user.clj seems to have what I want. The other missing piece, taking a string and then using it when calling require, is done with a call to (symbol name). (map #(ns-reload! (symbol %)) '("peg" "test.peg-test"))
Ball
Ok, good. I wasn't 100% sure the problem was, so I tried to touch on all the possible ones. user.clj was the first idea, and the other two paragraphs came later. Mark up another one for the value of gut responses!
Pinochle