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   581 use strict;
  10         23  
  10         400  
3 10     10   61 use warnings;
  10         20  
  10         677  
4              
5             our $VERSION = '1.302181';
6              
7              
8 10     10   62 use Test2::Util qw/pkg_to_file/;
  10         22  
  10         1286  
9              
10             our @EXPORT_OK = qw{
11             upgrade_suggested
12             upgrade_required
13             known_broken
14             };
15 10     10   70 BEGIN { require Exporter; our @ISA = qw(Exporter) }
  10         5802  
16              
17             sub upgrade_suggested {
18             return (
19 22     22 1 188 '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 317 '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 227 '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 105 my $class = shift;
64 26         63 my ($require) = @_;
65              
66 26         88 my %suggest = __PACKAGE__->upgrade_suggested();
67 26         110 my %required = __PACKAGE__->upgrade_required();
68 26         108 my %broken = __PACKAGE__->known_broken();
69              
70 26         74 my @warn;
71 26         116 for my $mod (keys %suggest) {
72 94         445 my $file = pkg_to_file($mod);
73 94 50 66     472 next unless $INC{$file} || ($require && eval { require $file; 1 });
  4   66     408  
  0         0  
74 2         5 my $want = $suggest{$mod};
75 2 100       3 next if eval { $mod->VERSION($want); 1 };
  2         36  
  1         5  
76 1         6 my $error = $@;
77 1         3 chomp $error;
78 1         6 push @warn => " * Module '$mod' is outdated, we recommed updating above $want. error was: '$error'; INC is $INC{$file}";
79             }
80              
81 26         246 for my $mod (keys %required) {
82 241         778 my $file = pkg_to_file($mod);
83 241 50 66     900 next unless $INC{$file} || ($require && eval { require $file; 1 });
  4   66     273  
  0         0  
84 2         3 my $want = $required{$mod};
85 2 100       4 next if eval { $mod->VERSION($want); 1 };
  2         22  
  1         4  
86 1         6 push @warn => " * Module '$mod' is outdated and known to be broken, please update to $want or higher.";
87             }
88              
89 26         239 for my $mod (keys %broken) {
90 199         869 my $file = pkg_to_file($mod);
91 199 50 66     777 next unless $INC{$file} || ($require && eval { require $file; 1 });
  4   66     272  
  0         0  
92 2         4 my $tested = $broken{$mod};
93 2         21 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         358 return @warn;
97             }
98              
99             1;
100              
101             __END__
102              
103              
104             =pod
105              
106             =encoding UTF-8
107              
108             =head1 NAME
109              
110             Test2::API::Breakage - What breaks at what version
111              
112             =head1 DESCRIPTION
113              
114             This module provides lists of modules that are broken, or have been broken in
115             the past, when upgrading L<Test::Builder> to use L<Test2>.
116              
117             =head1 FUNCTIONS
118              
119             These can be imported, or called as methods on the class.
120              
121             =over 4
122              
123             =item %mod_ver = upgrade_suggested()
124              
125             =item %mod_ver = Test2::API::Breakage->upgrade_suggested()
126              
127             This returns key/value pairs. The key is the module name, the value is the
128             version number. If the installed version of the module is at or below the
129             specified one then an upgrade would be a good idea, but not strictly necessary.
130              
131             =item %mod_ver = upgrade_required()
132              
133             =item %mod_ver = Test2::API::Breakage->upgrade_required()
134              
135             This returns key/value pairs. The key is the module name, the value is the
136             version number. If the installed version of the module is at or below the
137             specified one then an upgrade is required for the module to work properly.
138              
139             =item %mod_ver = known_broken()
140              
141             =item %mod_ver = Test2::API::Breakage->known_broken()
142              
143             This returns key/value pairs. The key is the module name, the value is the
144             version number. If the installed version of the module is at or below the
145             specified one then the module will not work. A newer version may work, but is
146             not tested or verified.
147              
148             =back
149              
150             =head1 SOURCE
151              
152             The source code repository for Test2 can be found at
153             F<http://github.com/Test-More/test-more/>.
154              
155             =head1 MAINTAINERS
156              
157             =over 4
158              
159             =item Chad Granum E<lt>exodist@cpan.orgE<gt>
160              
161             =back
162              
163             =head1 AUTHORS
164              
165             =over 4
166              
167             =item Chad Granum E<lt>exodist@cpan.orgE<gt>
168              
169             =back
170              
171             =head1 COPYRIGHT
172              
173             Copyright 2020 Chad Granum E<lt>exodist@cpan.orgE<gt>.
174              
175             This program is free software; you can redistribute it and/or
176             modify it under the same terms as Perl itself.
177              
178             See F<http://dev.perl.org/licenses/>
179              
180             =cut