Skip to content

Instantly share code, notes, and snippets.

@zamaterian
Created January 20, 2016 09:14
Show Gist options
  • Save zamaterian/7954374bda4b60ae696f to your computer and use it in GitHub Desktop.
Save zamaterian/7954374bda4b60ae696f to your computer and use it in GitHub Desktop.
Run a single clojure test within a fixture from vim
" depends on vim-fireplace
function! ClojureTestFixture() abort
"Eval the toplevel clojure form (a deftest) and then test-var the result.
"http://blog.venanti.us/clojure-vim/
normal! ^
let line1 = searchpair('(','',')', 'bcrn', g:fireplace#skip)
let line2 = searchpair('(','',')', 'rn', g:fireplace#skip)
let expr = join(getline(line1, line2), "\n")
let var = fireplace#session_eval(expr)
" only handles one fixture, look into clojure.test for examples combining the fixtures
let sexp = "(clojure.test/test-var ((or (first (:clojure.test/once-fixtures (meta *ns* ))) identity) " . var . "))"
" echo sexp
"
let result = fireplace#echo_session_eval(sexp)
return result
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment