]> git.vpit.fr Git - perl/modules/Test-Valgrind.git/blobdiff - lib/Test/Valgrind/Session.pm
Represent valgrind version numbers by their own class
[perl/modules/Test-Valgrind.git] / lib / Test / Valgrind / Session.pm
index ca586ea46caa7d4c91a28d57b61f1e73bb0e16c1..ba00ee24e02028b4ac7a7d6c4e6ddc2c97671f9e 100644 (file)
@@ -29,10 +29,10 @@ use Fcntl       (); # F_SETFD
 use IO::Select;
 use POSIX       (); # SIGKILL, _exit()
 
-use version ();
-
 use base qw<Test::Valgrind::Carp>;
 
+use Test::Valgrind::Version;
+
 =head1 METHODS
 
 =head2 C<new>
@@ -120,19 +120,20 @@ 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;
+ if (defined $min_version) {
+  $min_version = Test::Valgrind::Version->new(string => $min_version);
+ }
 
  my ($valgrind, $version);
  for (@paths) {
   next unless -x;
-  my $ver = qx/$_ --version/;
-  if ($ver =~ /^valgrind-(\d+(\.\d+)*)/) {
-   if ($min_version) {
-    $version = version->new($1);
-    next if $version < $min_version;
-   } else {
-    $version = $1;
-   }
+  my $output = qx/$_ --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 = $_;
    last;
   }
@@ -164,18 +165,7 @@ The path to the selected C<valgrind> executable.
 
     my $valgrind_version = $tvs->version;
 
-The L<version> object associated to the selected C<valgrind>.
-
-=cut
-
-sub version {
- my ($self) = @_;
-
- my $version = $self->{version};
- $self->{version} = $version = version->new($version) unless ref $version;
-
- return $version;
-}
+The L<Test::Valgrind::Version> object associated to the selected C<valgrind>.
 
 =head2 C<regen_def_supp>
 
@@ -201,6 +191,7 @@ Read-only accessor for the C<allow_no_supp> option.
 
 eval "sub $_ { \$_[0]->{$_} }" for qw<
  valgrind
+ version
  regen_def_supp
  no_def_supp
  allow_no_supp
@@ -625,7 +616,7 @@ sub status { $_[0]->{last_status} }
 
 L<Test::Valgrind>, L<Test::Valgrind::Action>, L<Test::Valgrind::Command>, L<Test::Valgrind::Tool>, L<Test::Valgrind::Parser>.
 
-L<version>, L<File::HomeDir>.
+L<File::HomeDir>.
 
 =head1 AUTHOR