How do you set up boot so that: (a) all source files are in the current directory, (b) unit tests run every time a source file is changed, (c) the REPL refreshes definitions when source files containing them change?
Specifically:
What goes in
build.boot
?What's the shell command to start the REPL? And/or what command in the REPL starts the watching of unit tests?
What other conventional set-up do I need to do?
I've read through a lot of documentation on boot, boot-test, boot-quick-test, REPL reloading in boot, and boot-refresh, but I haven't been able to get much to work. The documentation I've found so far seems to provide tidbits and hints but not what's needed to put these things together.
A simple example of an appropriate build.boot
(and whatever else) would be especially helpful.
So far, this is what I have that (sort of) works.
(set-env!
:dependencies '[
[adzerk/boot-test "1.1.2" :scope "test"]
[org.clojure/tools.namespace "0.2.11"]]
:source-paths #{"."})
(require '[clojure.tools.namespace.repl :as repl :refer [refresh]])
(apply repl/set-refresh-dirs (get-env :directories))
Plus one file in the current directory, sample.clj
:
(ns sample
(:require [clojure.test :refer :all]))
(defn myfunc [] "this string")
(deftest test-myfunc
(is (= "this string" (myfunc))))
This gets boot to find source files in the current directory, and it enables me to manually reload changes in sample.clj
by typing (refresh)
in the REPL. (boot (test))
used to manually run the unit tests in a .clj
file, but it failed when I tried it just now, with the error "Wrong number of args (0) passed to: core/test".
What's the right way to do this?