]> git.vpit.fr Git - perl/modules/Test-Valgrind.git/blobdiff - lib/Test/Valgrind/Parser/XML/Twig.pm
Miscellanous doc nits
[perl/modules/Test-Valgrind.git] / lib / Test / Valgrind / Parser / XML / Twig.pm
index 318e2dbb7ae20799027e9337e3abc6aec7ae62c4..7d5bf66e01c91029a1e836892ed9647d49983b53 100644 (file)
@@ -3,7 +3,24 @@ package Test::Valgrind::Parser::XML::Twig;
 use strict;
 use warnings;
 
-our $VERSION = '1.02';
+=head1 NAME
+
+Test::Valgrind::Parser::XML::Twig - Parse valgrind XML output with XML::Twig.
+
+=head1 VERSION
+
+Version 1.10
+
+=cut
+
+our $VERSION = '1.10';
+
+=head1 DESCRIPTION
+
+This subclass of L<XML::Twig> and L<Test::Valgrind::Parser::XML> encapsulates an L<XML::Twig> parser inside the L<Test::Valgrind::Parser> framework.
+It is able to parse the XML output from C<valgrind> up to protocol version 4 and to generate the appropriate reports accordingly.
+
+=cut
 
 use Scalar::Util ();
 
@@ -16,6 +33,10 @@ my %handlers = (
  '/valgrindoutput/error'           => \&handle_error,
 );
 
+=head1 METHODS
+
+=cut
+
 sub new {
  my $class = shift;
  $class = ref($class) || $class;
@@ -33,6 +54,13 @@ sub new {
 
 sub stash { shift->{Stash} }
 
+=head2 C<protocol_version>
+
+The version of the protocol that the current stream is conforming to.
+It is reset before and after the parsing phase, so it's effectively only available from inside L</parse>.
+
+=cut
+
 eval "sub $_ { \@_ <= 1 ? \$_[0]->{$_} : (\$_[0]->{$_} = \$_[1]) }"
                                               for qw/_session protocol_version/;
 
@@ -51,9 +79,13 @@ sub start {
 sub parse {
  my ($self, $sess, $fh) = @_;
 
+ $self->protocol_version(undef);
+
  $self->XML::Twig::parse($fh);
  $self->purge;
 
+ $self->protocol_version(undef);
+
  return;
 }
 
@@ -94,7 +126,7 @@ sub handle_error {
                                        $node->kid('stack')->children('frame') ];
 
  for (qw/leakedbytes leakedblocks/) {
-  my $kid = $node->first_child($_);
+  my $kid = ($xwhat || $node)->first_child($_);
   next unless $kid;
   $data->{$_} = int $kid->text;
  }
@@ -123,11 +155,42 @@ sub handle_error {
  $twig->purge;
 }
 
+=head1 SEE ALSO
+
+L<Test::Valgrind>, L<Test::Valgrind::Parser>, L<Test::Valgrind::Parser::XML>.
+
+L<XML::Twig>.
+
+=head1 AUTHOR
+
+Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
+
+You can contact me by mail or on C<irc.perl.org> (vincent).
+
+=head1 BUGS
+
+Please report any bugs or feature requests to C<bug-test-valgrind at rt.cpan.org>, or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Valgrind>.
+I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
+
+=head1 SUPPORT
+
+You can find documentation for this module with the perldoc command.
+
+    perldoc Test::Valgrind::Parser::XML::Twig
+
+=head1 COPYRIGHT & LICENSE
+
+Copyright 2009 Vincent Pit, all rights reserved.
+
+This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
+
+=cut
+
 # End of Test::Valgrind::Parser::XML::Twig
 
 package Test::Valgrind::Parser::XML::Twig::Elt;
 
-our $VERSION = '1.02';
+our $VERSION = '1.10';
 
 BEGIN { require XML::Twig; }