I can't tell you how many times I get tired of mysterious test behavior because someone forgot to put an 'or die' at the end of a use_ok() test. With this vim function, typing ',use' will convert all 'use_ok $package;' to have an 'or die' at the end.
map ,use :call UseOrDie()function! UseOrDie() %s/^\(\s*use_ok\s*(\?['"].*['"])\?\)\s*;/\1 or die;/ endfunction
For those not familiar with the problem, let's say you have 300 tests in one .t file. The 'use_ok' fails, but scrolls off the screen and if you forget to fix the first failure first, you get totally mystified by failures which occur later. I've had this happen to me several times and it's frustrating. use_ok() and require_ok() should both die. If you use require_ok(), you can switch the above to this:
map ,use :call UseOrDie()function! UseOrDie() %s/^\(\s*\(use\|require\)_ok\s*(\?['"].*['"])\?\)\s*;/\2 or die;/ endfunction
Re:Why use use_ok, require_ok at all?
Aristotle on 2007-12-11T16:27:07
Agreed.
Re:Another approach...
Ovid on 2007-12-12T10:41:44
That's what I've done with Test::Harness, but this isn't my code base.
Re:Another approach...
jplindstrom on 2007-12-12T23:29:15
It's our code base, including yours, no?
And I believe we already have a test file that loads all modules, but I'm not 100% certain (well, you shouldn't trust anything I say today anyway 8^)