File Coverage

blib/lib/Test2/API/Breakage.pm
Criterion Covered Total %
statement 46 49 93.8
branch 7 10 70.0
condition 12 18 66.6
subroutine 8 8 100.0
pod 1 1 100.0
total 74 86 86.0


line stmt bran cond sub pod time code
1             package Test2::API::Breakage;
2 4     4   1760 use strict;
  4         7  
  4         118  
3 4     4   16 use warnings;
  4         4  
  4         233  
4              
5             our $VERSION = '0.000043';
6             $VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval)
7              
8 4     4   13 use Test2::Util qw/pkg_to_file/;
  4         4  
  4         282  
9              
10             our @EXPORT_OK = qw{
11             upgrade_suggested
12             upgrade_required
13             known_broken
14             };
15 4     4   15 use base 'Exporter';
  4         4  
  4         1568  
16              
17             sub upgrade_suggested {
18             return (
19 20     20   111 '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 20     20   97 'Test::Builder::Clutch' => '0.07',
29             'Test::Dist::VersionSync' => '1.1.4',
30             'Test::Modern' => '0.012',
31             'Test::SharedFork' => '0.34',
32              
33             'Test::Clustericious::Cluster' => '0.31',
34             );
35             }
36              
37             sub known_broken {
38             return (
39 20     20   137 'Net::BitTorrent' => '0.052',
40             'Test::Aggregate' => '0.373',
41             'Test::Flatten' => '0.11',
42             'Test::Group' => '0.20',
43             'Test::More::Prefix' => '0.005',
44             'Test::ParallelSubtest' => '0.05',
45             'Test::Pretty' => '0.32',
46             'Test::Wrapper' => '0.3.0',
47              
48             'Test::DBIx::Class::Schema' => '1.0.9',
49             );
50             }
51              
52             sub report {
53 24     24 1 63 my $class = shift;
54 24         23 my ($require) = @_;
55              
56 24         45 my %suggest = __PACKAGE__->upgrade_suggested();
57 24         72 my %required = __PACKAGE__->upgrade_required();
58 24         56 my %broken = __PACKAGE__->known_broken();
59              
60 24         39 my @warn;
61 24         57 for my $mod (keys %suggest) {
62 86         354 my $file = pkg_to_file($mod);
63 86 50 66     277 next unless $INC{$file} || ($require && eval { require $file; 1 });
  4   66     410  
  0         0  
64 2         4 my $want = $suggest{$mod};
65 2 100       2 next if eval { $mod->VERSION($want); 1 };
  2         32  
  1         5  
66 1         5 push @warn => " * Module '$mod' is outdated, we recommed updating above $want.";
67             }
68              
69 24         234 for my $mod (keys %required) {
70 105         246 my $file = pkg_to_file($mod);
71 105 50 66     306 next unless $INC{$file} || ($require && eval { require $file; 1 });
  4   66     240  
  0         0  
72 2         4 my $want = $required{$mod};
73 2 100       1 next if eval { $mod->VERSION($want); 1 };
  2         17  
  1         3  
74 1         6 push @warn => " * Module '$mod' is outdated and known to be broken, please update to $want or higher.";
75             }
76              
77 24         166 for my $mod (keys %broken) {
78 181         344 my $file = pkg_to_file($mod);
79 181 50 66     500 next unless $INC{$file} || ($require && eval { require $file; 1 });
  4   66     236  
  0         0  
80 2         2 my $tested = $broken{$mod};
81 2         19 push @warn => " * Module '$mod' is known to be broken in version $tested and below, newer versions have not been tested. You have: " . $mod->VERSION;
82             }
83              
84 24         230 return @warn;
85             }
86              
87             1;
88              
89             __END__