X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FTest%2FValgrind%2FAction%2FSuppressions.pm;h=c80d56f42e9c92b752a7f96f75613861ab995eac;hb=90b6c795c9fab6343c3501923aacc8f43f7a82ea;hp=9f4d3fbecbe3fe2bf75adaff270a0402729a3779;hpb=abe419ac02d109283a1fe5615f5ab9d0a9a5572f;p=perl%2Fmodules%2FTest-Valgrind.git diff --git a/lib/Test/Valgrind/Action/Suppressions.pm b/lib/Test/Valgrind/Action/Suppressions.pm index 9f4d3fb..c80d56f 100644 --- a/lib/Test/Valgrind/Action/Suppressions.pm +++ b/lib/Test/Valgrind/Action/Suppressions.pm @@ -9,11 +9,11 @@ Test::Valgrind::Action::Suppressions - Generate suppressions for a given tool. =head1 VERSION -Version 1.01 +Version 1.12 =cut -our $VERSION = '1.01'; +our $VERSION = '1.12'; =head1 DESCRIPTION @@ -82,28 +82,7 @@ sub start { $self->SUPER::start($sess); - $self->{status} = undef; - $self->{total} = 0; - delete $self->{diagnostics}; - - if ($self->{fh}) { - close $self->{fh} or $self->_croak("close(\$self->{fh}): $!"); - } - - my $target = $self->target; - - require File::Spec; - my ($vol, $dir, $file) = File::Spec->splitpath($target); - my $base = File::Spec->catpath($vol, $dir, ''); - unless (-e $base) { - require File::Path; - File::Path::mkpath([ $base ]); - } else { - 1 while unlink $target; - } - - open $self->{fh}, '>', $target - or $self->_croak("open(\$self->{fh}, '>', \$self->target): $!"); + delete @{$self}{qw/status supps diagnostics/}; $self->save_fh(\*STDOUT => '>' => undef); $self->save_fh(\*STDERR => '>' => undef); @@ -136,12 +115,7 @@ sub report { $self->SUPER::report($sess, $report); - ++$self->{total}; - - print { $self->{fh} } "{\n" - . $self->name . $report->id . "\n" - . $report->data - . "}\n"; + push @{$self->{supps}}, $report; return; } @@ -153,11 +127,36 @@ sub finish { $self->restore_all_fh; - close $self->{fh} or $self->_croak("close(\$self->{fh}): $!"); - print $self->{diagnostics} if defined $self->{diagnostics}; delete $self->{diagnostics}; - print "Found $self->{total} distinct suppressions\n"; + + my $target = $self->target; + + require File::Spec; + my ($vol, $dir, $file) = File::Spec->splitpath($target); + my $base = File::Spec->catpath($vol, $dir, ''); + unless (-e $base) { + require File::Path; + File::Path::mkpath([ $base ]); + } else { + 1 while unlink $target; + } + + open my $fh, '>', $target + or $self->_croak("open(\$fh, '>', \$self->target): $!"); + + my (%seen, $id); + for (sort { $a->data cmp $b->data } + grep !$seen{$_->data}++, @{$self->{supps}}) { + print $fh "{\n" + . $self->name . ++$id . "\n" + . $_->data + . "}\n"; + } + + close $fh or $self->_croak("close(\$fh): $!"); + + print "Found $id distinct suppressions\n"; $self->{status} = 0;