From: Vincent Pit Date: Thu, 12 Nov 2015 16:46:10 +0000 (-0200) Subject: Make sure auxillary tests don't pick up the system valgrind X-Git-Tag: v1.16~3 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FTest-Valgrind.git;a=commitdiff_plain;h=139a661cde3aaf5fbf8883f35c0acaf77b8205ab Make sure auxillary tests don't pick up the system valgrind --- diff --git a/t/30-skip.t b/t/30-skip.t index f693a29..d073ace 100644 --- a/t/30-skip.t +++ b/t/30-skip.t @@ -3,6 +3,8 @@ use strict; use warnings; +BEGIN { delete $ENV{PATH} } + use lib 't/lib'; use VPIT::TestHelpers 'capture'; diff --git a/t/70-session.t b/t/70-session.t index 1ce46c5..c9c3cc4 100644 --- a/t/70-session.t +++ b/t/70-session.t @@ -3,6 +3,8 @@ use strict; use warnings; +BEGIN { delete $ENV{PATH} } + use Test::Valgrind::Session; use Test::More tests => 7; diff --git a/t/71-session-command.t b/t/71-session-command.t index 54ce89d..12e45e6 100644 --- a/t/71-session-command.t +++ b/t/71-session-command.t @@ -3,6 +3,8 @@ use strict; use warnings; +BEGIN { delete $ENV{PATH} } + use Test::More tests => 2; use Test::Valgrind::Command; diff --git a/t/80-suppressions.t b/t/80-suppressions.t index bc003f2..a57aca3 100644 --- a/t/80-suppressions.t +++ b/t/80-suppressions.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More; +use Test::More tests => 4; use Test::Valgrind::Command; use Test::Valgrind::Tool; @@ -59,57 +59,60 @@ my $tool = Test::Valgrind::Tool::Dummy->new(); my $dummy_action = Test::Valgrind::Action::Dummy->new(); -my $sess = eval { Test::Valgrind::Session->new( - min_version => $tool->requires_version, -) }; - -if (my $err = $@) { - $err =~ s/^(Empty valgrind candidates list|No appropriate valgrind executable could be found)\s+at.*/$1/; - plan skip_all => $err; -} else { - plan tests => 4; -} +SKIP: { + my $sess = eval { Test::Valgrind::Session->new( + min_version => $tool->requires_version, + ) }; + if (my $err = $@) { + if ($err =~ /^(Empty valgrind candidates list|No appropriate valgrind executable could be found)\s+at.*/) { + $err = $1; + } + skip $err => 2; + } -$sess->command($cmd); -$sess->tool($tool); - -my $file = $sess->def_supp_file; -my $VERSION = quotemeta $Test::Valgrind::Session::VERSION; -my $exp = qr!$VERSION/memcheck-\d+(?:\.\d+)*-[0-9a-f]{32}\.supp$!; -like $file, $exp, 'default suppression file is correctly named'; - -my $res = open my $supp_fh, '<', $file; -my $err = $!; -ok $res, 'default suppression file can be opened'; -diag "open($file): $err" unless $res; - -if ($res) { - my ($count, $non_empty, $perl_related) = (0, 0, 0); - my ($in, $valid_frames, $seen_perl); - while (<$supp_fh>) { - chomp; - s/^\s*//; - s/\s*$//; - if (!$in && $_ eq '{') { - $in = 1; - $valid_frames = 0; - $seen_perl = 0; - } elsif ($in) { - if ($_ eq '}') { - ++$count; - ++$non_empty if $valid_frames; - ++$perl_related if $seen_perl; - $in = 0; - } else { - ++$valid_frames if /^\s*fun:/; - ++$seen_perl if /^\s*fun:Perl_/; + $sess->command($cmd); + $sess->tool($tool); + + my $file = $sess->def_supp_file; + my $VERSION = quotemeta $Test::Valgrind::Session::VERSION; + my $exp = qr!$VERSION/memcheck-\d+(?:\.\d+)*-[0-9a-f]{32}\.supp$!; + like $file, $exp, 'default suppression file is correctly named'; + + my $res = open my $supp_fh, '<', $file; + my $err = $!; + ok $res, 'default suppression file can be opened'; + diag "open($file): $err" unless $res; + + if ($res) { + my ($count, $non_empty, $perl_related) = (0, 0, 0); + my ($in, $valid_frames, $seen_perl); + while (<$supp_fh>) { + chomp; + s/^\s*//; + s/\s*$//; + if (!$in && $_ eq '{') { + $in = 1; + $valid_frames = 0; + $seen_perl = 0; + } elsif ($in) { + if ($_ eq '}') { + ++$count; + ++$non_empty if $valid_frames; + ++$perl_related if $seen_perl; + $in = 0; + } else { + ++$valid_frames if /^\s*fun:/; + ++$seen_perl if /^\s*fun:Perl_/; + } } } + diag "The default suppression file contains $count suppressions, of which $non_empty are not empty and $perl_related apply to perl"; + close $supp_fh; } - diag "The default suppression file contains $count suppressions, of which $non_empty are not empty and $perl_related apply to perl"; - close $supp_fh; } +delete $ENV{PATH}; + SKIP: { my $dummy_vg = Test::Valgrind::FakeValgrind->new(); skip $dummy_vg => 2 unless ref $dummy_vg; diff --git a/t/81-suppressions-demangle.t b/t/81-suppressions-demangle.t index 232306b..65572c7 100644 --- a/t/81-suppressions-demangle.t +++ b/t/81-suppressions-demangle.t @@ -3,6 +3,8 @@ use strict; use warnings; +BEGIN { delete $ENV{PATH} } + use Test::More tests => 2 * 7; use Test::Valgrind::Suppressions;