Created
September 6, 2012 21:19
-
-
Save claco/3660445 to your computer and use it in GitHub Desktop.
Quick test running for test unit/rspec sans all the other plugins hupla.. current test under cursor, current file, current suite; puts errors in QuickFix. Uses m instead of testrb for test unit line support.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
autocmd BufNewFile,BufRead *_test.rb setlocal makeprg=m errorformat=%A%>\ \ %n)\ Failure:,%C%m\ [%f:%l]:,%Z | |
autocmd BufNewFile,BufRead *_test.rb setlocal makeprg=m errorformat+=%A%>\ \ %n)\ Error:,%C%.%#:,%C%m\ for\ #<%.%#>,%Z\ \ \ \ %f:%l:in\ \`%.%#\',%-G%.%# | |
"autocmd BufNewFile,BufRead *_spec.rb setlocal makeprg=rspec errorformat=rspec\ %f:%l\ #\ %m,%-G%.%# | |
autocmd BufNewFile,BufRead *_spec.rb setlocal makeprg=rspec errorformat=%A%>\ \ %n)%.%#,%C%>\ \ \ \ \ Failure/Error:%.%#,%C\ \ \ \ \ %m:,%C\ \ \ \ \ \ \ ,%C\ \ \ \ \ \ \ %m,%C\ \ \ \ \ #\ %f:%l:in%.%#,%Z,%-G%.%# | |
function! RunMake(...) | |
if a:0 == 1 | |
echo "Running " . &makeprg . " " . a:1 . "..." | |
silent exec "make! " . a:1 | |
elseif a:0 == 2 | |
echo "Running " . &makeprg . " " . a:1 . " -l " . a:2 . "..." | |
silent exec "make! " . a:1 . " -l " . a:2 | |
else | |
echo "Running " . &makeprg . "..." | |
silent exec "make!" | |
endif | |
redraw | |
if len(getqflist()) > 0 | |
cw | |
redraw | |
call RedBar('') | |
else | |
ccl | |
redraw | |
call GreenBar("") | |
endif | |
endfunction | |
command! TestSuite call RunMake() | |
command! TestFile call RunMake(expand('%')) | |
command! TestLine call RunMake(expand('%'), line('.')) | |
nmap \ts :TestSuite<CR> | |
nmap \tf :TestFile<CR> | |
nmap \tl :TestLine<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment