Stories
Slash Boxes
Comments

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)

Wednesday April 02, 2008
03:37 AM

Which Tests Cover This Code? :)

[ #36030 ]

Johan Lindstrom's Devel::CoverX::Covered is still relatively new, but here are some changes to my .vimrc based on this (stripped down for clarity):

function! PerlMappings()
    noremap <buffer> ,cv :call Coverage()<cr>
    noremap K :!perldoc <cword> <bar><bar> perldoc -f <cword><cr>
endfunction

function! PerlTestMappings()
    noremap <buffer> ,t :!prove -vl --norc %<CR>
endfunction

function! Coverage()
    let filename = bufname('%')
    if match(filename, '\.t$') > -1
        execute '!covered by --test_file="'. filename .'"'
    else
        execute '!covered covering --source_file="'. filename .'"'
    end
endfunction

au! FileType perl          :call PerlMappings()
au! BufRead,BufNewFile *.t :call PerlTestMappings()

When I am editing lib/Bermuda.pm and I type ,cv, I get this:

t/basic.t
t/bermuda.t
t/exceptions.t
t/serialize.t
t/subelements.t
t/xml.t

And if I'm editing t/basic.t and I type ,cv, I get this:

lib/Bermuda.pm
lib/Bermuda/Island.pm
lib/Bermuda/Island/Attribute.pm
lib/Berm uda/Island/Element.pm
lib/Bermuda/Island/Metadata.pm
lib/Bermuda/Parser.pm
li b/Bermuda/RNG.pm
lib/Bermuda/Writer.pm

In other words, know what tests will cover your code and vice versa. Johan has more features on the way, including being able to know which tests cover a particular line of a file.

Already I need to update my Oslo talk :)

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.