X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FTest-Valgrind.git;a=blobdiff_plain;f=lib%2FTest%2FValgrind%2FSession.pm;fp=lib%2FTest%2FValgrind%2FSession.pm;h=d222f11ae788a4d0394607ca3728325b1325002a;hp=ba00ee24e02028b4ac7a7d6c4e6ddc2c97671f9e;hb=5f7c59874ed712bf2787c3b0dbbaaf899fdd508c;hpb=63366af6711a7bcbaf8f1c0a78bc45ebb307124e diff --git a/lib/Test/Valgrind/Session.pm b/lib/Test/Valgrind/Session.pm index ba00ee2..d222f11 100644 --- a/lib/Test/Valgrind/Session.pm +++ b/lib/Test/Valgrind/Session.pm @@ -22,7 +22,9 @@ It also acts as a dispatcher between the different components. =cut +use Config (); use File::Spec (); +use ExtUtils::MM (); # MM->maybe_command() use Scalar::Util (); use Fcntl (); # F_SETFD @@ -111,10 +113,12 @@ sub new { if (defined $vg and not ref $vg) { @paths = ($vg); } else { - push @paths, @$vg if $vg and ref $vg eq 'ARRAY'; + push @paths, @$vg if defined $vg and ref $vg eq 'ARRAY'; my $dirs = delete $args{search_dirs}; - $dirs = [ File::Spec->path ] unless $dirs; - push @paths, map File::Spec->catfile($_, 'valgrind'), @$dirs + $dirs = [ File::Spec->path ] unless defined $dirs; + my $exe_name = 'valgrind'; + $exe_name .= $Config::Config{exe_ext} if defined $Config::Config{exe_ext}; + push @paths, map File::Spec->catfile($_, $exe_name), @$dirs if ref $dirs eq 'ARRAY'; } $class->_croak('Empty valgrind candidates list') unless @paths; @@ -125,16 +129,16 @@ sub new { } my ($valgrind, $version); - for (@paths) { - next unless -x; - my $output = qx/$_ --version/; + for my $path (@paths) { + next unless defined($path) and MM->maybe_command($path); + my $output = qx/$path --version/; $version = do { local $@; eval { Test::Valgrind::Version->new(command_output => $output) }; }; if (defined $version) { next if defined $min_version and $version < $min_version; - $valgrind = $_; + $valgrind = $path; last; } }