Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Ovid (2709)

Ovid
  (email not shown publicly)
http://publius-ovidius.livejournal.com/
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Thursday August 03, 2006
05:14 AM

Better testing with vim!

[ #30522 ]

If you read this post, you'll notice that my Test::Class driver script allows the following syntax:

t/test_class_tests.t path/to/test/class/to/run.pm

However, some of my tests are in Test::Class style and some of my tests are old-style test scripts. I bound two keys in vim to handle them (,T and ,t, respectively), but that was annoying, so I just wrote this:

if exists( "perl_tests" )
    finish
endif
let perl_tests = 1

noremap <silent> ,t :call RunTests()<cr>

function RunTests()
    if match(getline(1), 'package') > -1
        execute ":!perl t/test_class_tests.t %"
    else
        execute ":!prove -lv %"
    endif
endfunction

If you're using my Test::Class driver script or a similar variation and you save the above in something like ~/.vim/plugin/PerlTests.vim, then whenever you hit ,t, you will run the tests in whatever test file you're working on. It assumes that all Test::Class files have a package declaration on the first line, though, so not everyone will be happy with that. Improvements welcome!

Checking to see if a file is named test.pl, ends in .t or is a regular package which actually uses Test::Class would be good improvements.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.