From: Vincent Pit Date: Fri, 30 Oct 2015 15:47:59 +0000 (-0200) Subject: Add 'regen_def_supp', an option to regenerate the suppressions X-Git-Tag: v1.15~2 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=b62067c81672ff40a3fcda54cb498feae33b752f;p=perl%2Fmodules%2FTest-Valgrind.git Add 'regen_def_supp', an option to regenerate the suppressions And use it in t/10-good.t so that all the tests are run with a fresh suppression file. --- diff --git a/lib/Test/Valgrind.pm b/lib/Test/Valgrind.pm index 5e95a9f..a1f2e32 100644 --- a/lib/Test/Valgrind.pm +++ b/lib/Test/Valgrind.pm @@ -108,11 +108,11 @@ Ignored if you supply your own custom C, otherwise defaults to false. =item * -C<< extra_supps => \@files >> +C<< regen_def_supp => $bool >> -Also use suppressions from C<@files> besides C's. +If true, forcefully regenerate the default suppression file. -Defaults to empty. +Defaults to false. =item * @@ -122,6 +122,14 @@ If true, do not use the default suppression file. Defaults to false. +=item * + +C<< extra_supps => \@files >> + +Also use suppressions from C<@files> besides C's. + +Defaults to empty. + =back =cut @@ -168,7 +176,7 @@ sub analyse { my $sess = eval { Test::Valgrind::Session->new( min_version => $tool->requires_version, - map { $_ => delete $args{$_} } qw + map { $_ => delete $args{$_} } qw ); }; unless ($sess) { diff --git a/lib/Test/Valgrind/Session.pm b/lib/Test/Valgrind/Session.pm index 4aefd49..bbafa56 100644 --- a/lib/Test/Valgrind/Session.pm +++ b/lib/Test/Valgrind/Session.pm @@ -37,12 +37,13 @@ use base qw; =head2 C 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 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 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 + + my $regen_def_supp = $tvs->regen_def_supp; + +Read-only accessor for the C option. + +=cut + =head2 C my $no_def_supp = $tvs->no_def_supp; @@ -168,7 +184,7 @@ Read-only accessor for the C option. =cut -eval "sub $_ { \$_[0]->{$_} }" for qw; +eval "sub $_ { \$_[0]->{$_} }" for qw; =head2 C @@ -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( diff --git a/t/10-good.t b/t/10-good.t index 0d56967..fee58e3 100644 --- a/t/10-good.t +++ b/t/10-good.t @@ -9,7 +9,10 @@ use lib 't/lib'; eval { require Test::Valgrind; - Test::Valgrind->import(diag => 1); + Test::Valgrind->import( + diag => 1, + regen_def_supp => 1, + ); }; if ($@) { diag $@;