http://qs321.pair.com?node_id=435186


in reply to Re^2: Test driven development with Perl and vim
in thread Test driven development with Perl and vim

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.

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/" endif if g:testfile == "t/" || g:testfile =~ "\.t$" if a:verbose echo system("prove -vl " . g:testfile . " 2>&1 | tee " . & +errorfile) else echo system("prove -l " . g:testfile . " 2>&1 | tee " . &e +rrorfile) endif else call Compile () endif cfile endfunction function! Compile () if ! exists("g:compilefile") let g:compilefile = expand("%") endif execute "!perl -wc -Ilib " . g:compilefile cfile endfunction 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 +estfile<cr> nmap ,W :unlet g:testfile<cr>:echo "testfile undefined; will run all t +ests"<cr> " based on compiler/perl.vim by Christian J. Robinson <infynity@onewes +t.net> " added formats for test failures set errorformat= \%-G%.%#had\ compilation\ errors., \%-G%.%#syntax\ OK, \%+Anot\ ok\%.%#-\ %m, \%C%.%#\(%f\ at\ line\ %l\), \%m\ at\ %f\ line\ %l., \%+A%.%#\ at\ %f\ line\ %l\\,%.%#, \%+C%.%# " FIXME make this more local. Needed for redirection syntax which isn' +t csh compatible set sh=/bin/sh " Just more convenient when shelling out a lot. set autowrite

The main changes are:

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.