From: Vincent Pit Date: Tue, 14 Apr 2009 14:27:50 +0000 (+0200) Subject: Really allow to pass "file => $file" to Test::Valgrind->import X-Git-Tag: v1.01~4 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=14d9a30088d40282446f97180ac6e383fa9ababf;p=perl%2Fmodules%2FTest-Valgrind.git Really allow to pass "file => $file" to Test::Valgrind->import --- diff --git a/lib/Test/Valgrind.pm b/lib/Test/Valgrind.pm index 601a949..3c52e85 100644 --- a/lib/Test/Valgrind.pm +++ b/lib/Test/Valgrind.pm @@ -220,22 +220,27 @@ sub import { return; } - my ($file, $pm, $next); - my $l = 0; - while ($l < 1000) { - $next = (caller $l++)[1]; - last unless defined $next; - next if $next eq '-e' or $next =~ /^\s*\(\s*eval\s*\d*\s*\)\s*$/ or !-f $next; - if ($next =~ /\.pm$/) { - $pm = $next; - } else { - $file = $next; + my $file = delete $args{file}; + unless (defined $file) { + my ($pm, $next); + my $l = 0; + while ($l < 1000) { + $next = (caller $l++)[1]; + last unless defined $next; + next if $next eq '-e' + or $next =~ /^\s*\(\s*eval\s*\d*\s*\)\s*$/ + or !-f $next; + if ($next =~ /\.pm$/) { + $pm = $next; + } else { + $file = $next; + } + } + unless (defined($file) or defined($file = $pm)) { + require Test::Builder; + Test::Builder->new->diag('Couldn\'t find a valid source file'); + return; } - } - unless (defined($file) or defined($file = $pm)) { - require Test::Builder; - Test::Builder->new->diag('Couldn\'t find a valid source file'); - return; } exit $class->analyse(