=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;
}
my @args = (
$self->valgrind,
- '--log-fd=' . fileno($vwtr),
$self->tool->args($self),
@supp_args,
+ $self->parser->args($self, $vwtr),
$self->command->args($self),
);
close $vwtr or $self->_croak("close(\$vwtr): $!");
- $self->tool->parse($self, $vrdr);
+ $self->parser->parse($self, $vrdr);
$self->{exit_code} = (waitpid($pid, 0) == $pid) ? $? >> 8 : 255;
Read-only accessor for the C<tool> associated to the current run.
+=head2 C<parser>
+
+Read-only accessor for the C<parser> associated to the current tool.
+
=head2 C<command>
Read-only accessor for the C<command> associated to the current run.
my @members;
BEGIN {
- @members = qw/action tool command/;
+ @members = qw/action tool command parser/;
for (@members) {
eval "sub $_ { \@_ <= 1 ? \$_[0]->{$_} : (\$_[0]->{$_} = \$_[1]) }";
die if $@;
my %args = @_;
- for (@members) {
+ for (qw/action tool command/) {
my $base = 'Test::Valgrind::' . ucfirst;
my $value = $args{$_};
$self->_croak("Invalid $_") unless Scalar::Util::blessed($value)
delete @{$self}{qw/last_status exit_code/};
$self->tool->start($self);
+ $self->parser($self->tool->parser_class($self)->new)->start($self);
$self->action->start($self);
return;
sub abort {
my $self = shift;
+
$self->action->abort($self, @_);
}
return unless defined $report;
- $report = $self->command->filter($self, $report);
- return unless defined $report;
+ for my $handler (qw/tool command/) {
+ $report = $self->$handler->filter($self, $report);
+ return unless defined $report;
+ }
$self->action->report($self, $report);
}
my ($self) = @_;
my $action = $self->action;
+
$action->finish($self);
+ $self->parser->finish($self);
$self->tool->finish($self);
my $status = $action->status($self);
=head1 SEE ALSO
-L<Test::Valgrind>, L<Test::Valgrind::Action>, L<Test::Valgrind::Tool>, L<Test::Valgrind::Command>.
+L<Test::Valgrind>, L<Test::Valgrind::Action>, L<Test::Valgrind::Command>, L<Test::Valgrind::Tool>, L<Test::Valgrind::Parser>.
L<version>, L<File::HomeDir>.