]> git.vpit.fr Git - perl/modules/Test-Valgrind.git/blobdiff - lib/Test/Valgrind/Tool.pm
Factor the start/finish logic into a new Test::Valgrind::Component base class
[perl/modules/Test-Valgrind.git] / lib / Test / Valgrind / Tool.pm
index 054ce4f764c45c647085eb4b89a33f08ebfd9073..a82b95d676632a0f65c0e6d632375908b6ab3105 100644 (file)
@@ -9,11 +9,11 @@ Test::Valgrind::Tool - Base class for Test::Valgrind tools.
 
 =head1 VERSION
 
-Version 1.00
+Version 1.02
 
 =cut
 
-our $VERSION = '1.00';
+our $VERSION = '1.02';
 
 =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,7 +58,7 @@ sub new {
   return $tool->new(%args);
  }
 
bless { }, $class;
$class->SUPER::new(@_);
 }
 
 =head2 C<new_trainer>
@@ -116,7 +116,7 @@ Defaults to the empty list.
 
 =cut
 
-sub args  { }
+sub args { }
 
 =head2 C<suppressions_tag $session>
 
@@ -132,21 +132,20 @@ sub suppressions_tag;
 
 Called when the C<$session> starts.
 
-Defaults to void.
-
-=cut
-
-sub start { }
+Defaults to set L<Test::Valgrind::Component/started>.
 
 =head2 C<parse $session, $fh>
 
 Wraps around either L</parse_suppressions> or L</parse_analysis> 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 {
@@ -156,7 +155,7 @@ sub parse {
 
 =head2 C<parse_suppressions $sesssion, $fh>
 
-Parse the suppression reports sent by the C<valgrind> process attached to the session C<$session> through the filehandle C<$fh>.
+Parse the suppression reports that the C<valgrind> process attached to the session C<$session> send through the filehandle C<$fh>.
 
 This method must be implemented when subclassing.
 
@@ -178,15 +177,11 @@ sub parse_analysis;
 
 Called when the C<$session> finishes.
 
-Defaults to void.
-
-=cut
-
-sub finish { }
+Defaults to clear L<Test::Valgrind::Component/started>.
 
 =head1 SEE ALSO
 
-L<Test::Valgrind>, L<Test::Valgrind::Session>.
+L<Test::Valgrind>, L<Test::Valgrind::Component>, L<Test::Valgrind::Session>.
 
 =head1 AUTHOR