Skip to content

Instantly share code, notes, and snippets.

@jebberjeb
Last active August 29, 2015 13:56
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 jebberjeb/9114733 to your computer and use it in GitHub Desktop.
Save jebberjeb/9114733 to your computer and use it in GitHub Desktop.
Use vim-fireplace to run unit tests, highlight failed test fns in red!
function! RunTests()
" reload the namespace
norm cpr
" setup
call clearmatches()
highlight Red ctermbg=darkred
redir => output
" use Clojure to do the real work, run tests,
" parse the results
Eval (map #(subs % 9 (dec (count %))) (re-seq #"FAIL in \(\S*\)" (let [s# (new java.io.StringWriter)] (binding [*test-out* s#] (run-all-tests) (str s#)))))
redir END
" output will have the valid ('a-fn' 'b-fn')
" strip off the parens, then split on space
let output = output[2:len(output) - 2]
let parts = split(output, ' ')
" highlight each match
for part in parts
exec "call matchadd('Red'," . part . ")"
endfor
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment