From: Vincent Pit Date: Sat, 19 Sep 2009 22:56:28 +0000 (+0200) Subject: Don't scan for valgrind at configure time X-Git-Tag: v1.10~10 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FTest-Valgrind.git;a=commitdiff_plain;h=5ee5c767e23b5c9c7660a2a0fda30962ef924d65 Don't scan for valgrind at configure time 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. --- diff --git a/Makefile.PL b/Makefile.PL index 3ffa8fb..14d276e 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -4,28 +4,12 @@ use strict; 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 @@ -82,15 +66,8 @@ my $dist = 'Test-Valgrind'; 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, diff --git a/lib/Test/Valgrind/Session.pm b/lib/Test/Valgrind/Session.pm index fe521a0..c7240b9 100644 --- a/lib/Test/Valgrind/Session.pm +++ b/lib/Test/Valgrind/Session.pm @@ -22,15 +22,13 @@ It also acts as a dispatcher between the different components. =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/; @@ -78,11 +76,6 @@ Defaults to none. =cut -my $build_version = sub { - require version; - version->new($_[0]); -}; - sub new { my $class = shift; $class = ref($class) || $class; @@ -103,7 +96,7 @@ sub new { $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) { @@ -111,7 +104,7 @@ sub new { 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; @@ -149,7 +142,7 @@ sub version { 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; } diff --git a/t/80-suppressions.t b/t/80-suppressions.t index b9266a5..b6f22c7 100644 --- a/t/80-suppressions.t +++ b/t/80-suppressions.t @@ -3,11 +3,10 @@ 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( @@ -19,9 +18,15 @@ my $tool = Test::Valgrind::Tool->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);