]> git.vpit.fr Git - perl/modules/Test-Valgrind.git/commitdiff
Always strip wildcard frames at the end of a suppression
authorVincent Pit <vince@profvince.com>
Tue, 3 Nov 2009 13:17:31 +0000 (14:17 +0100)
committerVincent Pit <vince@profvince.com>
Tue, 3 Nov 2009 13:20:21 +0000 (14:20 +0100)
Thanks to a new Test::Valgrind::Suppressions->strip_tail helper.

lib/Test/Valgrind/Parser/Suppressions/Text.pm
lib/Test/Valgrind/Suppressions.pm

index 19ef138de0171552e26ddf6b289c81b5c3e0417a..6eb2dfcf54b2e44da1b537066bfa64e78a478e2b 100644 (file)
@@ -21,6 +21,8 @@ This is a L<Test::Valgrind::Parser::Text> object that can extract suppressions f
 
 =cut
 
 
 =cut
 
+use Test::Valgrind::Suppressions;
+
 use base qw/Test::Valgrind::Parser::Text Test::Valgrind::Carp/;
 
 =head1 METHODS
 use base qw/Test::Valgrind::Parser::Text Test::Valgrind::Carp/;
 
 =head1 METHODS
@@ -54,13 +56,7 @@ sub parse {
   if ($_ eq '{') {      # A suppression block begins
    $in = 1;
   } elsif ($_ eq '}') { # A suppression block ends
   if ($_ eq '{') {      # A suppression block begins
    $in = 1;
   } elsif ($_ eq '}') { # A suppression block ends
-   # With valgrind 3.4.0, we can replace unknown series of frames by '...'
-   if ($sess->version ge '3.4.0') {
-    my $unknown_tail;
-    ++$unknown_tail while $s =~ s/(\n)\s*obj:\*\s*$/$1/;
-    $s .= "...\n" if $unknown_tail;
-   }
-
+   $s = Test::Valgrind::Suppressions->strip_tail($sess, $s); # Strip the tail
    push @supps, $s;     # Add the suppression that just ended to the list
    $s  = '';            # Reset the state
    $in = 0;
    push @supps, $s;     # Add the suppression that just ended to the list
    $s  = '';            # Reset the state
    $in = 0;
index 800a7c79bc94c5ed87a68f2d997e7e50307c5edc..fde934c050948e0a047b554664483b029364c1e7 100644 (file)
@@ -88,6 +88,26 @@ sub generate {
  return $status;
 }
 
  return $status;
 }
 
+=head2 C<strip_tail $session, $suppression>
+
+Removes all wildcard frames at the end of the suppression.
+Moreover, C<'...'> is appended when C<valgrind> C<3.4.0> or higher is used.
+Returns the mangled suppression.
+
+=cut
+
+sub strip_tail {
+ shift;
+
+ my ($sess, $supp) = @_;
+
+ 1 while $supp =~ s/[^\r\n]*:\s*\*\s*$//;
+ # With valgrind 3.4.0, we can replace unknown series of frames by '...'
+ $supp .= "...\n" if $sess->version ge '3.4.0';
+
+ $supp;
+}
+
 =head1 SEE ALSO
 
 L<Test::Valgrind>, L<Test::Valgrind::Command>, L<Test::Valgrind::Tool>, L<Test::Valgrind::Action::Suppressions>.
 =head1 SEE ALSO
 
 L<Test::Valgrind>, L<Test::Valgrind::Command>, L<Test::Valgrind::Tool>, L<Test::Valgrind::Action::Suppressions>.