Actually, as I discovered after posting, it's a lot easier to write a Compile() function that you get to control (like adding -Ilib) than depending on vim's make. So, I took that out. Plus, I found a few things better than BufNewFile and BufRead.
in reply to Re^2: Test driven development with Perl and vim
in thread Test driven development with Perl and vim
This is how my .exrc snippet looks now:
autocmd BufNewFile,BufRead *.p? so ~/.vim/perltest.vim
autocmd BufEnter *.p? colors peachpuff
autocmd BufNewFile,BufRead *.t so ~/.vim/perltest.vim
autocmd BufEnter *.t colors blue
And, I make a few changes to my perltest.vim
" perltest.vim - test driven development for Perl with vim
" ,t -- Run tests
" ,w -- Set current file as test file. Only this test will run.
" ,W -- Unset current test file. All tests will run.
" Updates at http://perlmonks.org/index.pl?node_id=434793
function! Prove ( verbose )
if ! exists("g:testfile")
let g:testfile = "t/"
if g:testfile == "t/" || g:testfile =~ "\.t$"
echo system("prove -vl " . g:testfile . " 2>&1 | tee " . &
echo system("prove -l " . g:testfile . " 2>&1 | tee " . &e
call Compile ()
function! Compile ()
if ! exists("g:compilefile")
let g:compilefile = expand("%")
execute "!perl -wc -Ilib " . g:compilefile
nmap ,t :call Prove (0)<cr>
nmap ,T :call Prove (1)<cr>
nmap ,v :call Compile ()<cr>
nmap ,w :let g:testfile = expand("%")<cr>:echo "testfile is now" g:t
nmap ,W :unlet g:testfile<cr>:echo "testfile undefined; will run all t
" based on compiler/perl.vim by Christian J. Robinson <infynity@onewes
" added formats for test failures
\%-G%.%#had\ compilation\ errors.,
\%+Anot\ ok\%.%#-\ %m,
\%C%.%#\(%f\ at\ line\ %l\),
\%m\ at\ %f\ line\ %l.,
\%+A%.%#\ at\ %f\ line\ %l\\,%.%#,
" FIXME make this more local. Needed for redirection syntax which isn'
+t csh compatible
" Just more convenient when shelling out a lot.
The main changes are:
- Addition of ,T allowing for make test TEST_VERBOSE=1
- Addition of ,v allowing for compile of .t files. This entailed creating Compile()
- Addition of -l flag to prove, keeping the vim editor in the same directory as the tags file.
I'm still figuring out the various parameters. Heck, I've learned more about the vim settings in the last hour than I had in the 10+ years I've been using vi-based editors! :-)
Being right, does not endow the right to be rude; politeness costs nothing.
Being unknowing, is not the same as being stupid.
Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.