File Coverage

blib/lib/Test2/API/Breakage.pm
Criterion Covered Total %
statement 47 50 94.0
branch 7 10 70.0
condition 12 18 66.6
subroutine 8 8 100.0
pod 3 4 75.0
total 77 90 85.5


line stmt bran cond sub pod time code
1             package Test2::API::Breakage;
2 10     10   635 use strict;
  10         24  
  10         387  
3 10     10   67 use warnings;
  10         18  
  10         729  
4              
5             our $VERSION = '1.302180';
6              
7              
8 10     10   63 use Test2::Util qw/pkg_to_file/;
  10         30  
  10         1163  
9              
10             our @EXPORT_OK = qw{
11             upgrade_suggested
12             upgrade_required
13             known_broken
14             };
15 10     10   67 BEGIN { require Exporter; our @ISA = qw(Exporter) }
  10         5757  
16              
17             sub upgrade_suggested {
18             return (
19 22     22 1 252 'Test::Exception' => '0.42',
20             'Test::FITesque' => '0.04',
21             'Test::Module::Used' => '0.2.5',
22             'Test::Moose::More' => '0.025',
23             );
24             }
25              
26             sub upgrade_required {
27             return (
28 22     22 1 251 'Test::Builder::Clutch' => '0.07',
29             'Test::Dist::VersionSync' => '1.1.4',
30             'Test::Modern' => '0.012',
31             'Test::SharedFork' => '0.34',
32             'Test::Alien' => '0.04',
33             'Test::UseAllModules' => '0.14',
34             'Test::More::Prefix' => '0.005',
35              
36             'Test2::Tools::EventDumper' => 0.000007,
37             'Test2::Harness' => 0.000013,
38              
39             'Test::DBIx::Class::Schema' => '1.0.9',
40             'Test::Clustericious::Cluster' => '0.30',
41             );
42             }
43              
44             sub known_broken {
45             return (
46 22     22 1 197 'Net::BitTorrent' => '0.052',
47             'Test::Able' => '0.11',
48             'Test::Aggregate' => '0.373',
49             'Test::Flatten' => '0.11',
50             'Test::Group' => '0.20',
51             'Test::ParallelSubtest' => '0.05',
52             'Test::Pretty' => '0.32',
53             'Test::Wrapper' => '0.3.0',
54              
55             'Log::Dispatch::Config::TestLog' => '0.02',
56             );
57             }
58              
59             # Not reportable:
60             # Device::Chip => 0.07 - Tests will not pass, but not broken if already installed, also no fixed version we can upgrade to.
61              
62             sub report {
63 26     26 0 97 my $class = shift;
64 26         62 my ($require) = @_;
65              
66 26         88 my %suggest = __PACKAGE__->upgrade_suggested();
67 26         100 my %required = __PACKAGE__->upgrade_required();
68 26         113 my %broken = __PACKAGE__->known_broken();
69              
70 26         67 my @warn;
71 26         117 for my $mod (keys %suggest) {
72 94         396 my $file = pkg_to_file($mod);
73 94 50 66     401 next unless $INC{$file} || ($require && eval { require $file; 1 });
  4   66     410  
  0         0  
74 2         4 my $want = $suggest{$mod};
75 2 100       4 next if eval { $mod->VERSION($want); 1 };
  2         34  
  1         7  
76 1         5 my $error = $@;
77 1         4 chomp $error;
78 1         8 push @warn => " * Module '$mod' is outdated, we recommed updating above $want. error was: '$error'; INC is $INC{$file}";
79             }
80              
81 26         252 for my $mod (keys %required) {
82 241         631 my $file = pkg_to_file($mod);
83 241 50 66     1017 next unless $INC{$file} || ($require && eval { require $file; 1 });
  4   66     263  
  0         0  
84 2         4 my $want = $required{$mod};
85 2 100       3 next if eval { $mod->VERSION($want); 1 };
  2         24  
  1         6  
86 1         6 push @warn => " * Module '$mod' is outdated and known to be broken, please update to $want or higher.";
87             }
88              
89 26         228 for my $mod (keys %broken) {
90 199         899 my $file = pkg_to_file($mod);
91 199 50 66     746 next unless $INC{$file} || ($require && eval { require $file; 1 });
  4   66     263  
  0         0  
92 2         3 my $tested = $broken{$mod};
93 2         20 push @warn => " * Module '$mod' is known to be broken in version $tested and below, newer versions have not been tested. You have: " . $mod->VERSION;
94             }
95              
96 26         324 return @warn;
97             }
98              
99             1;
100              
101             __END__