]> git.vpit.fr Git - perl/modules/indirect.git/blob - t/21-bad-use.t
Show more information when we couldn't run the tests data files
[perl/modules/indirect.git] / t / 21-bad-use.t
1 #!perl
2
3 use strict;
4 use warnings;
5
6 my $total;
7 BEGIN {
8  $total = 28;
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           '-Mindirect',
20           '-c',
21           't/data/bad.d'
22    ];
23 $stderr = join '', @$stderr;
24 unless ($success) {
25  diag $stderr;
26  diag "Failed to execute data file (error $err_code)";
27  fail "Couldn't run test $_" for 1 .. $total + 1;
28 }
29
30 my %fail;
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 ($m =~ /^(?:new|potato)(\d+)$/) {
37   $id = $1;
38  } elsif ($o =~ /^Hlagh(\d+)$/) {
39   $id = $1;
40  } else {
41   diag "$m $o";
42   ++$extra_fail;
43  }
44  if ($id) {
45   fail("test $id shouldn't have failed");
46   $fail{$id} = 1;
47  }
48 }
49
50 pass("test $_ hasn't failed") for grep { !$fail{$_} } 1 .. $total;
51 is($extra_fail, 0, 'no extra fails');