Easier Test Debugging

The vast majority of the time when I run the debugger on a test, I get frustrated because I have to wait for the test to load, then type '{l' (always list next window of lines before the debugger prompt) and then 'c' (continue to breakpoint -- because I've almost always set one at this point).

So I dropped this into my $HOME/.perldb file:

sub afterinit { 
    push @DB::typeahead, "{l", "c"

And in my vim config (where you put it will vary depending on your setup), I have this:

    noremap <buffer> <leader>D :!DEBUGGING_TESTS=1 perl -d -Ilib %<cr>

With that, I hit ',D' (comma D) and my debugger starts up and runs to my breakpoint for me, rather than me getting annoyed at typing those instructions at the start of every debugger sections. I really need to read perldoc perldebug more carefully. There are some lovely tidbits of information there.

Long term, I'm thinking about combining some tricks with Devel::CoverX::Covered such that I can use that module with a custom $HOME/.perldb file to simply insert a breakpoint in my code (not the test) and automatically have the appropriate test run to that point without me doing anything more than simply adding a breakpoint. No more hunting for tests when narrowing down a bug.


sounds really interesting, I want that too! :)

Ovid, I would love to see your .vimrc :-)

Leave a comment

About Ovid

user-pic Have Perl; Will Travel. Freelance Perl/Testing/Agile consultant. Photo by http://www.circle23.com/. Warning: that site is not safe for work. The photographer is a good friend of mine, though, and it's appropriate to credit his work.