We don't need this anymore since suppressions are now generated on the fly.
This removes almost all configure_requires dependencies.
The module ought to handle systems where valgrind is not present anyway.
use warnings;
use ExtUtils::MakeMaker;
-my $has_version_pm;
BEGIN {
eval { require Config };
die 'OS unsupported' if $@;
Config->import(qw/%Config/);
eval { require File::Spec };
die 'OS unsupported' if $@;
- $has_version_pm = eval "require version; 1" || 0;
-}
-use lib 'lib';
-
-print 'Checking for valgrind ' . ('>= 3.1.0 ' x $has_version_pm) .'in PATH... ';
-require Test::Valgrind::Session;
-my $vg = eval q[
- Test::Valgrind::Session->new((min_version => '3.1.0') x $has_version_pm)
- ->valgrind
-];
-if ($vg) {
- print "$vg\n";
-} else {
- print "no\n";
- die 'OS unsupported';
}
# Inspired from Module::Install::Can
my %META = (
configure_requires => {
- 'Carp' => 0,
- 'Config' => 0,
- 'ExtUtils::MakeMaker' => 0,
- 'Fcntl' => 0,
'File::Spec' => 0,
- 'POSIX' => 0,
- 'Scalar::Util' => 0,
- 'base' => 0,
- 'version' => 0,
+ 'ExtUtils::MakeMaker' => 0,
},
build_requires => {
'ExtUtils::MakeMaker' => 0,
=cut
-# All these modules are required at configure time.
+use File::Spec ();
+use Scalar::Util ();
-BEGIN {
- require File::Spec;
- require Scalar::Util;
+use Fcntl (); # F_SETFD
+use POSIX (); # SIGKILL
- require Fcntl; # F_SETFD
- require POSIX; # SIGKILL
-}
+use version ();
use base qw/Test::Valgrind::Carp/;
=cut
-my $build_version = sub {
- require version;
- version->new($_[0]);
-};
-
sub new {
my $class = shift;
$class = ref($class) || $class;
$class->_croak('Empty valgrind candidates list') unless @paths;
my $min_version = delete $args{min_version};
- defined and not ref and $_ = $build_version->($_) for $min_version;
+ defined and not ref and $_ = version->new($_) for $min_version;
my ($valgrind, $version);
for (@paths) {
my $ver = qx/$_ --version/;
if ($ver =~ /^valgrind-(\d+(\.\d+)*)/) {
if ($min_version) {
- $version = $build_version->($1);
+ $version = version->new($1);
next if $version < $min_version;
} else {
$version = $1;
my ($self) = @_;
my $version = $self->{version};
- $self->{version} = $version = $build_version->($version) unless ref $version;
+ $self->{version} = $version = version->new($version) unless ref $version;
return $version;
}
use strict;
use warnings;
-use Test::More tests => 4;
+use Test::More;
use Test::Valgrind::Command;
use Test::Valgrind::Tool;
-use Test::Valgrind::Action;
use Test::Valgrind::Session;
my $cmd = Test::Valgrind::Command->new(
tool => 'memcheck',
);
-my $sess = Test::Valgrind::Session->new(
+my $sess = eval { Test::Valgrind::Session->new(
min_version => $tool->requires_version,
-);
+) };
+
+if ($@) {
+ plan skip_all => $@;
+} else {
+ plan tests => 4;
+}
$sess->command($cmd);
$sess->tool($tool);