X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F70-session.t;fp=t%2F70-session.t;h=3bfa7d0de2e2b86d436670255e9167290857b15b;hb=1676ebac042f1bf93c0639beb6b33ee471c063db;hp=0000000000000000000000000000000000000000;hpb=b53c95bc4c9013591c3051dd69d472518474d620;p=perl%2Fmodules%2FTest-Valgrind.git diff --git a/t/70-session.t b/t/70-session.t new file mode 100644 index 0000000..3bfa7d0 --- /dev/null +++ b/t/70-session.t @@ -0,0 +1,63 @@ +#!perl + +use strict; +use warnings; + +use Test::Valgrind::Session; + +use File::Temp; + +use Test::More tests => 7; + +my $sess = eval { Test::Valgrind::Session->new( + search_dirs => [ ], +) }; +like $@, qr/^Empty valgrind candidates list/, 'no search_dirs'; + +$sess = eval { Test::Valgrind::Session->new( + valgrind => 'wut', +) }; +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 +} + +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 $sess = eval { Test::Valgrind::Session->new( + valgrind => $vg_old->filename, + 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; + +$sess = eval { Test::Valgrind::Session->new( + valgrind => $vg_new->filename, + min_version => '3.1.0', +) }; +is $@, '', 'new valgrind'; +isa_ok $sess, 'Test::Valgrind::Session', 'new valgrind isa Test::Valgrind::Session'; + +$sess = eval { Test::Valgrind::Session->new( + search_dirs => [ ], + valgrind => [ $vg_old->filename, $vg_new->filename ], + min_version => '3.1.0', +) }; +is $@, '', 'old and new valgrind'; +isa_ok $sess, 'Test::Valgrind::Session', 'old and new valgrind isa Test::Valgrind::Session';