Skip to content

Instantly share code, notes, and snippets.

@haruyama
Created May 1, 2013 07:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haruyama/5494097 to your computer and use it in GitHub Desktop.
Save haruyama/5494097 to your computer and use it in GitHub Desktop.
clojure autotest using vim-fireplace
function! s:run_tests(filename)
let template = '(require ''clojure.tools.namespace) (require ''clojure.test) (let [namespaces (clojure.tools.namespace/find-namespaces-in-dir (java.io.File. "%s"))] (doseq [ns namespaces] (prn ns) (require ns :reload) (if (re-find #"-test\z" (name ns)) (clojure.test/run-tests ns) (try (let [test-ns (symbol (str (name ns) "-test"))] (prn test-ns) (require test-ns :reload) (clojure.test/run-tests test-ns)) (catch Exception e (.getMessage e))))))'
let exp = printf(template, escape(a:filename, '"\'))
call fireplace#session_eval(exp)
endfunction
autocmd! BufWritePost *.clj call s:run_tests(expand("<afile>"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment