X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FTest%2FValgrind%2FTool.pm;h=7560d52217e64663a11af909a9102c1ac70ae934;hb=08860dad1f820cce06758ec4add9353a4dbc8175;hp=a1211af7fb3a3dedaf668ca290980d677cfa15db;hpb=8a51ed6220d0fb2e29c669011bdf733c347b60f4;p=perl%2Fmodules%2FTest-Valgrind.git diff --git a/lib/Test/Valgrind/Tool.pm b/lib/Test/Valgrind/Tool.pm index a1211af..7560d52 100644 --- a/lib/Test/Valgrind/Tool.pm +++ b/lib/Test/Valgrind/Tool.pm @@ -9,11 +9,11 @@ Test::Valgrind::Tool - Base class for Test::Valgrind tools. =head1 VERSION -Version 1.02 +Version 1.10 =cut -our $VERSION = '1.02'; +our $VERSION = '1.10'; =head1 DESCRIPTION @@ -24,7 +24,7 @@ They are expected to function both in suppressions generation and in analysis mo =cut -use base qw/Test::Valgrind::Carp/; +use base qw/Test::Valgrind::Component Test::Valgrind::Carp/; =head1 METHODS @@ -58,11 +58,7 @@ sub new { return $tool->new(%args); } - my $self = bless { }, $class; - - $self->started(undef); - - $self; + $class->SUPER::new(@_); } =head2 C @@ -75,41 +71,25 @@ Defaults to return C, which skips suppression generation. sub new_trainer { } -=head2 C - -Wraps around either L or L depending on the running mode of the C<$session>. - -=cut - -sub report_class { - my ($self, $sess) = @_; - - if ($sess->do_suppressions) { - $self->report_class_suppressions($sess); - } else { - $self->report_class_analysis($sess); - } -} - -=head2 C +=head2 C -Returns the class in which suppression reports generated by this tool will be blessed. +Returns the class from which the parser for this tool output will be instanciated. This method must be implemented when subclassing. =cut -sub report_class_suppression; +sub parser_class; -=head2 C +=head2 C -Returns the class in which error reports generated by this tool will be blessed. +Returns the class in which suppression reports generated by this tool will be blessed. This method must be implemented when subclassing. =cut -sub report_class_analysis; +sub report_class; =head2 C @@ -132,90 +112,32 @@ This method must be implemented when subclassing. sub suppressions_tag; -=head2 C - -Specifies whether the tool is running (C<1>), stopped (C<0>) or was never started (C). - -=cut - -sub started { @_ <= 1 ? $_[0]->{started} : ($_[0]->{started} = $_[1]) } - =head2 C Called when the C<$session> starts. -Defaults to set L. - -=cut - -sub start { - my ($self) = @_; - - $self->_croak('Tool already started') if $self->started; - $self->started(1); - - return; -} - -=head2 C - -Wraps around either L or L depending on the running mode of the C<$session>. -Croaks if the tool isn't started. - -=cut - -sub parse { - my ($self, $sess, $fh) = @_; - - $self->_croak('Tool isn\'t started') unless $self->started; - - if ($sess->do_suppressions) { - $self->parse_suppressions($sess, $fh); - } else { - $self->parse_analysis($sess, $fh); - } -} - -=head2 C - -Parse the suppression reports that the C process attached to the session C<$session> send through the filehandle C<$fh>. +Defaults to set L. -This method must be implemented when subclassing. - -=cut +=head2 C -sub parse_suppressions; +The <$session> calls this method after receiving a report from the parser and before letting the command filter it. +You can either return a mangled C<$report> (which does not need to be a clone of the original) or C if you want the action to ignore it completely. -=head2 C - -Parse the error reports sent by the C process attached to the session C<$session> through the filehandle C<$fh>. - -This method must be implemented when subclassing. +Defaults to the identity function. =cut -sub parse_analysis; +sub filter { $_[2] } =head2 C Called when the C<$session> finishes. -Defaults to clear L. - -=cut - -sub finish { - my ($self) = @_; - - return unless $self->started; - $self->started(0); - - return; -} +Defaults to clear L. =head1 SEE ALSO -L, L. +L, L, L. =head1 AUTHOR