]> git.vpit.fr Git - perl/modules/Test-Valgrind.git/blob - t/70-session.t
Update VPIT::TestHelpers to 15e8aee3
[perl/modules/Test-Valgrind.git] / t / 70-session.t
1 #!perl
2
3 use strict;
4 use warnings;
5
6 BEGIN { delete $ENV{PATH} }
7
8 use Test::Valgrind::Session;
9
10 use Test::More tests => 7;
11
12 use lib 't/lib';
13 use Test::Valgrind::FakeValgrind;
14
15 my $sess = eval { Test::Valgrind::Session->new(
16  search_dirs => [ ],
17 ) };
18 like $@, qr/^Empty valgrind candidates list/, 'no search_dirs';
19
20 $sess = eval { Test::Valgrind::Session->new(
21  valgrind => 'wut',
22 ) };
23 like $@, qr/^No appropriate valgrind executable/, 'nonexistant valgrind';
24
25 SKIP: {
26  my $old_vg = Test::Valgrind::FakeValgrind->new(
27   version => '3.0.0',
28  );
29  skip $old_vg => 5 unless ref $old_vg;
30
31  my $sess = eval { Test::Valgrind::Session->new(
32   valgrind    => $old_vg->path,
33   min_version => '3.1.0',
34  ) };
35  like $@, qr/^No appropriate valgrind executable/, 'old valgrind';
36
37  my $new_vg = Test::Valgrind::FakeValgrind->new(
38   version => '3.4.0',
39  );
40  skip $new_vg => 4 unless ref $new_vg;
41
42  $sess = eval { Test::Valgrind::Session->new(
43   valgrind    => $new_vg->path,
44   min_version => '3.1.0',
45  ) };
46  is     $@,    '',                        'new valgrind';
47  isa_ok $sess, 'Test::Valgrind::Session', 'new valgrind isa Test::Valgrind::Session';
48
49  $sess = eval { Test::Valgrind::Session->new(
50   search_dirs => [ ],
51   valgrind    => [ $old_vg->path, $new_vg->path ],
52   min_version => '3.1.0',
53  ) };
54  is     $@,    '',                        'old and new valgrind';
55  isa_ok $sess, 'Test::Valgrind::Session', 'old and new valgrind isa Test::Valgrind::Session';
56 }