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