]> git.vpit.fr Git - perl/modules/Test-Valgrind.git/blobdiff - lib/Test/Valgrind/Session.pm
Add 'regen_def_supp', an option to regenerate the suppressions
[perl/modules/Test-Valgrind.git] / lib / Test / Valgrind / Session.pm
index 4aefd49b920d23c62887b2e56abc5a0c91afbbeb..bbafa5620500c137a9280b6fb0913d0ada8577ce 100644 (file)
@@ -37,12 +37,13 @@ use base qw<Test::Valgrind::Carp>;
 =head2 C<new>
 
     my $tvs = Test::Valgrind::Session->new(
-     search_dirs => \@search_dirs,
-     valgrind    => $valgrind,  # One candidate
-     valgrind    => \@valgrind, # Several candidates
-     min_version => $min_version,
-     no_def_supp => $no_def_supp,
-     extra_supps => \@extra_supps,
+     search_dirs    => \@search_dirs,
+     valgrind       => $valgrind,  # One candidate
+     valgrind       => \@valgrind, # Several candidates
+     min_version    => $min_version,
+     regen_def_supp => $regen_def_supp,
+     no_def_supp    => $no_def_supp,
+     extra_supps    => \@extra_supps,
     );
 
 The package constructor, which takes several options :
@@ -71,7 +72,13 @@ Defaults to none.
 
 =item *
 
-If C<$no_def_supp> is false, C<valgrind> won't read the default suppression file associated with the tool and the command.
+If C<$regen_def_supp> is true, the default suppression file associated with the tool and the command will be forcefully regenerated.
+
+Defaults to false.
+
+=item *
+
+If C<$no_def_supp> is true, C<valgrind> won't read the default suppression file associated with the tool and the command.
 
 Defaults to false.
 
@@ -130,10 +137,11 @@ sub new {
  @$extra_supps   = grep { defined && -f $_ && -r _ } @$extra_supps;
 
  bless {
-  valgrind    => $valgrind,
-  version     => $version,
-  no_def_supp => delete($args{no_def_supp}),
-  extra_supps => $extra_supps,
+  valgrind       => $valgrind,
+  version        => $version,
+  regen_def_supp => delete($args{regen_def_supp}),
+  no_def_supp    => delete($args{no_def_supp}),
+  extra_supps    => $extra_supps,
  }, $class;
 }
 
@@ -160,6 +168,14 @@ sub version {
  return $version;
 }
 
+=head2 C<regen_def_supp>
+
+    my $regen_def_supp = $tvs->regen_def_supp;
+
+Read-only accessor for the C<regen_def_supp> option.
+
+=cut
+
 =head2 C<no_def_supp>
 
     my $no_def_supp = $tvs->no_def_supp;
@@ -168,7 +184,7 @@ Read-only accessor for the C<no_def_supp> option.
 
 =cut
 
-eval "sub $_ { \$_[0]->{$_} }" for qw<valgrind no_def_supp>;
+eval "sub $_ { \$_[0]->{$_} }" for qw<valgrind regen_def_supp no_def_supp>;
 
 =head2 C<extra_supps>
 
@@ -226,9 +242,14 @@ sub _run {
   push @supp_args, '--gen-suppressions=all';
  } elsif (not $self->no_def_supp) {
   my $def_supp = $self->def_supp_file;
+  my $forced;
+  if ($self->regen_def_supp and -e $def_supp) {
+   1 while unlink $def_supp;
+   $forced = 1;
+  }
   if (defined $def_supp and not -e $def_supp) {
    $self->report($self->report_class->new_diag(
-    "Generating suppressions..."
+    'Generating suppressions' . ($forced ? ' (forced)' : '') . '...'
    ));
    require Test::Valgrind::Suppressions;
    Test::Valgrind::Suppressions->generate(