From: Vincent Pit Date: Tue, 14 Apr 2009 13:52:15 +0000 (+0200) Subject: Allow passing a command to Test::Valgrind->import X-Git-Tag: v1.01~6 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FTest-Valgrind.git;a=commitdiff_plain;h=27bd94a9be93ea328e072a879a18a80dde0053d0 Allow passing a command to Test::Valgrind->import --- diff --git a/lib/Test/Valgrind.pm b/lib/Test/Valgrind.pm index a447541..4b33486 100644 --- a/lib/Test/Valgrind.pm +++ b/lib/Test/Valgrind.pm @@ -47,6 +47,14 @@ You can pass parameters to C as a list of key / value pairs, where valid =item * +C<< command => $command >> + +The L object (or class name) to use. + +Defaults to L. + +=item * + C<< tool => $tool >> The L object (or class name) to use. @@ -136,18 +144,21 @@ sub import { return; } - require Test::Valgrind::Command; - my $cmd = Test::Valgrind::Command->new( - command => 'PerlScript', - file => $file, - args => [ '-MTest::Valgrind=run,1' ], - ); - my $instanceof = sub { require Scalar::Util; Scalar::Util::blessed($_[0]) && $_[0]->isa($_[1]); }; + my $cmd = delete $args{command}; + unless ($cmd->$instanceof('Test::Valgrind::Command')) { + require Test::Valgrind::Command; + $cmd = Test::Valgrind::Command->new( + command => $cmd || 'PerlScript', + file => $file, + args => [ '-MTest::Valgrind=run,1' ], + ); + } + my $tool = delete $args{tool}; unless ($tool->$instanceof('Test::Valgrind::Tool')) { require Test::Valgrind::Tool;