X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FTest%2FValgrind%2FSession.pm;h=b95c1d60c8a1a001ea8deab71099d398b641885b;hb=023a29965a41dc85c2250bd8c673b9d5b69746ba;hp=6c09793a91e20c08e28c973613f0f16794a3e88c;hpb=3a859aa7502f69dbe6445a1eee8af49250f823d0;p=perl%2Fmodules%2FTest-Valgrind.git diff --git a/lib/Test/Valgrind/Session.pm b/lib/Test/Valgrind/Session.pm index 6c09793..b95c1d6 100644 --- a/lib/Test/Valgrind/Session.pm +++ b/lib/Test/Valgrind/Session.pm @@ -30,8 +30,6 @@ BEGIN { require Fcntl; # F_SETFD require POSIX; # SIGKILL - - require version; } use base qw/Test::Valgrind::Carp/; @@ -82,6 +80,11 @@ Defaults to none. =cut +my $build_version = sub { + require version; + version->new($_[0]); +}; + sub new { my $class = shift; $class = ref($class) || $class; @@ -102,15 +105,19 @@ sub new { $class->_croak('Empty valgrind candidates list') unless @paths; my $min_version = delete $args{min_version}; - defined and not ref and $_ = version->new($_) for $min_version; + defined and not ref and $_ = $build_version->($_) for $min_version; my ($valgrind, $version); for (@paths) { next unless -x; my $ver = qx/$_ --version/; if ($ver =~ /^valgrind-(\d+(\.\d+)*)/) { - $version = version->new($1); - next if $min_version and $version < $min_version; + if ($min_version) { + $version = $build_version->($1); + next if $version < $min_version; + } else { + $version = $1; + } $valgrind = $_; last; } @@ -138,13 +145,24 @@ The path to the selected C executable. The L object associated to the selected C. +=cut + +sub version { + my ($self) = @_; + + my $version = $self->{version}; + $self->{version} = $version = $build_version->($version) unless ref $version; + + return $version; +} + =head2 C Read-only accessor for the C option. =cut -eval "sub $_ { \$_[0]->{$_} }" for qw/valgrind version no_def_supp/; +eval "sub $_ { \$_[0]->{$_} }" for qw/valgrind no_def_supp/; =head2 C