]> git.vpit.fr Git - perl/modules/indirect.git/blob - t/30-scope.t
Show more information when we couldn't run the tests data files
[perl/modules/indirect.git] / t / 30-scope.t
1 #!perl
2
3 use strict;
4 use warnings;
5
6 my $total;
7 BEGIN {
8  $total = 8;
9 }
10
11 use Test::More tests => $total + 1;
12
13 use IPC::Cmd qw/run/;
14
15 (my $success, my $err_code, undef, undef, my $stderr)
16  = run command => [
17           $^X,
18           map('-I' . $_, @INC),
19           '-c',
20           't/data/mixed.d'
21    ];
22 $stderr = join '', @$stderr;
23 unless ($success) {
24  diag $stderr;
25  diag "Failed to execute data file (error $err_code)";
26  fail "Couldn't run test $_" for 1 .. $total + 1;
27 }
28
29 my %fail = map { $_ => 1 } 2, 3, 5, 7;
30 my %failed;
31 my $extra_fail = 0;
32
33 while ($stderr =~ /^Indirect\s+call\s+of\s+method\s+"([^"]+)"\s+on\s+object\s+"([^"]+)"/mg) {
34  my ($m, $o) = ($1, $2);
35  my $id;
36  if ($o =~ /^P(\d+)$/) {
37   $id = $1;
38  } else {
39   diag "$m $o";
40   ++$extra_fail;
41  }
42  if ($id) {
43   if (exists $fail{$id}) {
44    pass("test $id failed as expected");
45    delete $fail{$id};
46    $failed{$id} = 1;
47   } else {
48    fail("test $id shouldn't have failed");
49   }
50  }
51 }
52
53 pass("test $_ hasn't failed") for grep { !$failed{$_} } 1 .. $total;
54 fail("test $_ should have failed") for sort { $a <=> $b } keys %fail;
55 is($extra_fail, 0, 'no extra fails');