X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F70-session.t;h=c9c3cc4e28f3ba226a32a5c3219a081c82f59d69;hb=139a661cde3aaf5fbf8883f35c0acaf77b8205ab;hp=22c78cd15a0f9084185fcf9514d830eead523cf8;hpb=f365ebc2c6b2d39f049bb9ef20b45a6b2728466a;p=perl%2Fmodules%2FTest-Valgrind.git diff --git a/t/70-session.t b/t/70-session.t index 22c78cd..c9c3cc4 100644 --- a/t/70-session.t +++ b/t/70-session.t @@ -3,12 +3,15 @@ use strict; use warnings; -use Test::Valgrind::Session; +BEGIN { delete $ENV{PATH} } -use File::Temp; +use Test::Valgrind::Session; use Test::More tests => 7; +use lib 't/lib'; +use Test::Valgrind::FakeValgrind; + my $sess = eval { Test::Valgrind::Session->new( search_dirs => [ ], ) }; @@ -19,39 +22,27 @@ $sess = eval { Test::Valgrind::Session->new( ) }; like $@, qr/^No appropriate valgrind executable/, 'nonexistant valgrind'; -sub fake_vg { - my ($version) = @_; - return <<" FAKE_VG"; -#!$^X -if (\@ARGV == 1 && \$ARGV[0] eq '--version') { - print "valgrind-$version\n"; -} else { - print "hlagh\n"; -} - FAKE_VG -} - SKIP: { skip 'Only on linux or darwin' => 5 unless $^O eq 'linux' or $^O eq 'darwin'; - my $vg_old = File::Temp->new(UNLINK => 1); - print $vg_old fake_vg('3.0.0'); - close $vg_old; - chmod 0755, $vg_old->filename; + my $old_vg = Test::Valgrind::FakeValgrind->new( + version => '3.0.0', + ); + skip $old_vg => 5 unless ref $old_vg; my $sess = eval { Test::Valgrind::Session->new( - valgrind => $vg_old->filename, + valgrind => $old_vg->path, min_version => '3.1.0', ) }; like $@, qr/^No appropriate valgrind executable/, 'old valgrind'; - my $vg_new = File::Temp->new(UNLINK => 1); - print $vg_new fake_vg('3.4.0'); - close $vg_new; - chmod 0755, $vg_new->filename; + my $new_vg = Test::Valgrind::FakeValgrind->new( + version => '3.4.0', + ); + skip $new_vg => 4 unless ref $new_vg; $sess = eval { Test::Valgrind::Session->new( - valgrind => $vg_new->filename, + valgrind => $new_vg->path, min_version => '3.1.0', ) }; is $@, '', 'new valgrind'; @@ -59,7 +50,7 @@ SKIP: { $sess = eval { Test::Valgrind::Session->new( search_dirs => [ ], - valgrind => [ $vg_old->filename, $vg_new->filename ], + valgrind => [ $old_vg->path, $new_vg->path ], min_version => '3.1.0', ) }; is $@, '', 'old and new valgrind';