This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Upgrade Test::Simple from version 1.302056 to 1.302059
[perl5.git] / cpan / Test-Simple / lib / Test2 / API / Breakage.pm
1 package Test2::API::Breakage;
2 use strict;
3 use warnings;
4
5 our $VERSION = '1.302059';
6
7
8 use Test2::Util qw/pkg_to_file/;
9
10 our @EXPORT_OK = qw{
11     upgrade_suggested
12     upgrade_required
13     known_broken
14 };
15 BEGIN { require Exporter; our @ISA = qw(Exporter) }
16
17 sub upgrade_suggested {
18     return (
19         '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         '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
35         'Test::Clustericious::Cluster' => '0.30',
36     );
37 }
38
39 sub known_broken {
40     return (
41         'Net::BitTorrent'       => '0.052',
42         'Test::Able'            => '0.11',
43         'Test::Aggregate'       => '0.373',
44         'Test::Flatten'         => '0.11',
45         'Test::Group'           => '0.20',
46         'Test::More::Prefix'    => '0.005',
47         'Test::ParallelSubtest' => '0.05',
48         'Test::Pretty'          => '0.32',
49         'Test::Wrapper'         => '0.3.0',
50
51         'Test::DBIx::Class::Schema'      => '1.0.9',
52         'Log::Dispatch::Config::TestLog' => '0.02',
53     );
54 }
55
56 # Not reportable:
57 # Device::Chip => 0.07   - Tests will not pass, but not broken if already installed, also no fixed version we can upgrade to.
58
59 sub report {
60     my $class = shift;
61     my ($require) = @_;
62
63     my %suggest  = __PACKAGE__->upgrade_suggested();
64     my %required = __PACKAGE__->upgrade_required();
65     my %broken   = __PACKAGE__->known_broken();
66
67     my @warn;
68     for my $mod (keys %suggest) {
69         my $file = pkg_to_file($mod);
70         next unless $INC{$file} || ($require && eval { require $file; 1 });
71         my $want = $suggest{$mod};
72         next if eval { $mod->VERSION($want); 1 };
73         push @warn => " * Module '$mod' is outdated, we recommed updating above $want.";
74     }
75
76     for my $mod (keys %required) {
77         my $file = pkg_to_file($mod);
78         next unless $INC{$file} || ($require && eval { require $file; 1 });
79         my $want = $required{$mod};
80         next if eval { $mod->VERSION($want); 1 };
81         push @warn => " * Module '$mod' is outdated and known to be broken, please update to $want or higher.";
82     }
83
84     for my $mod (keys %broken) {
85         my $file = pkg_to_file($mod);
86         next unless $INC{$file} || ($require && eval { require $file; 1 });
87         my $tested = $broken{$mod};
88         push @warn => " * Module '$mod' is known to be broken in version $tested and below, newer versions have not been tested. You have: " . $mod->VERSION;
89     }
90
91     return @warn;
92 }
93
94 1;
95
96 __END__
97
98
99 =pod
100
101 =encoding UTF-8
102
103 =head1 NAME
104
105 Test2::API::Breakage - What breaks at what version
106
107 =head1 DESCRIPTION
108
109 This module provides lists of modules that are broken, or have been broken in
110 the past, when upgrading L<Test::Builder> to use L<Test2>.
111
112 =head1 FUNCTIONS
113
114 These can be imported, or called as methods on the class.
115
116 =over 4
117
118 =item %mod_ver = upgrade_suggested()
119
120 =item %mod_ver = Test2::API::Breakage->upgrade_suggested()
121
122 This returns key/value pairs. The key is the module name, the value is the
123 version number. If the installed version of the module is at or below the
124 specified one then an upgrade would be a good idea, but not strictly necessary.
125
126 =item %mod_ver = upgrade_required()
127
128 =item %mod_ver = Test2::API::Breakage->upgrade_required()
129
130 This returns key/value pairs. The key is the module name, the value is the
131 version number. If the installed version of the module is at or below the
132 specified one then an upgrade is required for the module to work properly.
133
134 =item %mod_ver = known_broken()
135
136 =item %mod_ver = Test2::API::Breakage->known_broken()
137
138 This returns key/value pairs. The key is the module name, the value is the
139 version number. If the installed version of the module is at or below the
140 specified one then the module will not work. A newer version may work, but is
141 not tested or verified.
142
143 =back
144
145 =head1 SOURCE
146
147 The source code repository for Test2 can be found at
148 F<http://github.com/Test-More/test-more/>.
149
150 =head1 MAINTAINERS
151
152 =over 4
153
154 =item Chad Granum E<lt>exodist@cpan.orgE<gt>
155
156 =back
157
158 =head1 AUTHORS
159
160 =over 4
161
162 =item Chad Granum E<lt>exodist@cpan.orgE<gt>
163
164 =back
165
166 =head1 COPYRIGHT
167
168 Copyright 2016 Chad Granum E<lt>exodist@cpan.orgE<gt>.
169
170 This program is free software; you can redistribute it and/or
171 modify it under the same terms as Perl itself.
172
173 See F<http://dev.perl.org/licenses/>
174
175 =cut