This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
a69e8ba4272cdc663c126d1075058f1eb834c83e
[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.302169';
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         '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         '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     my $class = shift;
64     my ($require) = @_;
65
66     my %suggest  = __PACKAGE__->upgrade_suggested();
67     my %required = __PACKAGE__->upgrade_required();
68     my %broken   = __PACKAGE__->known_broken();
69
70     my @warn;
71     for my $mod (keys %suggest) {
72         my $file = pkg_to_file($mod);
73         next unless $INC{$file} || ($require && eval { require $file; 1 });
74         my $want = $suggest{$mod};
75         next if eval { $mod->VERSION($want); 1 };
76         push @warn => " * Module '$mod' is outdated, we recommend updating above $want.";
77     }
78
79     for my $mod (keys %required) {
80         my $file = pkg_to_file($mod);
81         next unless $INC{$file} || ($require && eval { require $file; 1 });
82         my $want = $required{$mod};
83         next if eval { $mod->VERSION($want); 1 };
84         push @warn => " * Module '$mod' is outdated and known to be broken, please update to $want or higher.";
85     }
86
87     for my $mod (keys %broken) {
88         my $file = pkg_to_file($mod);
89         next unless $INC{$file} || ($require && eval { require $file; 1 });
90         my $tested = $broken{$mod};
91         push @warn => " * Module '$mod' is known to be broken in version $tested and below, newer versions have not been tested. You have: " . $mod->VERSION;
92     }
93
94     return @warn;
95 }
96
97 1;
98
99 __END__
100
101
102 =pod
103
104 =encoding UTF-8
105
106 =head1 NAME
107
108 Test2::API::Breakage - What breaks at what version
109
110 =head1 DESCRIPTION
111
112 This module provides lists of modules that are broken, or have been broken in
113 the past, when upgrading L<Test::Builder> to use L<Test2>.
114
115 =head1 FUNCTIONS
116
117 These can be imported, or called as methods on the class.
118
119 =over 4
120
121 =item %mod_ver = upgrade_suggested()
122
123 =item %mod_ver = Test2::API::Breakage->upgrade_suggested()
124
125 This returns key/value pairs. The key is the module name, the value is the
126 version number. If the installed version of the module is at or below the
127 specified one then an upgrade would be a good idea, but not strictly necessary.
128
129 =item %mod_ver = upgrade_required()
130
131 =item %mod_ver = Test2::API::Breakage->upgrade_required()
132
133 This returns key/value pairs. The key is the module name, the value is the
134 version number. If the installed version of the module is at or below the
135 specified one then an upgrade is required for the module to work properly.
136
137 =item %mod_ver = known_broken()
138
139 =item %mod_ver = Test2::API::Breakage->known_broken()
140
141 This returns key/value pairs. The key is the module name, the value is the
142 version number. If the installed version of the module is at or below the
143 specified one then the module will not work. A newer version may work, but is
144 not tested or verified.
145
146 =back
147
148 =head1 SOURCE
149
150 The source code repository for Test2 can be found at
151 F<http://github.com/Test-More/test-more/>.
152
153 =head1 MAINTAINERS
154
155 =over 4
156
157 =item Chad Granum E<lt>exodist@cpan.orgE<gt>
158
159 =back
160
161 =head1 AUTHORS
162
163 =over 4
164
165 =item Chad Granum E<lt>exodist@cpan.orgE<gt>
166
167 =back
168
169 =head1 COPYRIGHT
170
171 Copyright 2019 Chad Granum E<lt>exodist@cpan.orgE<gt>.
172
173 This program is free software; you can redistribute it and/or
174 modify it under the same terms as Perl itself.
175
176 See F<http://dev.perl.org/licenses/>
177
178 =cut