1package Test2::API::Breakage; 2use strict; 3use warnings; 4 5our $VERSION = '1.302199'; 6 7 8use Test2::Util qw/pkg_to_file/; 9 10our @EXPORT_OK = qw{ 11 upgrade_suggested 12 upgrade_required 13 known_broken 14}; 15BEGIN { require Exporter; our @ISA = qw(Exporter) } 16 17sub 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 26sub 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 44sub 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 62sub 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 my $error = $@; 77 chomp $error; 78 push @warn => " * Module '$mod' is outdated, we recommend updating above $want. error was: '$error'; INC is $INC{$file}"; 79 } 80 81 for my $mod (keys %required) { 82 my $file = pkg_to_file($mod); 83 next unless $INC{$file} || ($require && eval { require $file; 1 }); 84 my $want = $required{$mod}; 85 next if eval { $mod->VERSION($want); 1 }; 86 push @warn => " * Module '$mod' is outdated and known to be broken, please update to $want or higher."; 87 } 88 89 for my $mod (keys %broken) { 90 my $file = pkg_to_file($mod); 91 next unless $INC{$file} || ($require && eval { require $file; 1 }); 92 my $tested = $broken{$mod}; 93 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 return @warn; 97} 98 991; 100 101__END__ 102 103 104=pod 105 106=encoding UTF-8 107 108=head1 NAME 109 110Test2::API::Breakage - What breaks at what version 111 112=head1 DESCRIPTION 113 114This module provides lists of modules that are broken, or have been broken in 115the past, when upgrading L<Test::Builder> to use L<Test2>. 116 117=head1 FUNCTIONS 118 119These 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 127This returns key/value pairs. The key is the module name, the value is the 128version number. If the installed version of the module is at or below the 129specified 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 135This returns key/value pairs. The key is the module name, the value is the 136version number. If the installed version of the module is at or below the 137specified 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 143This returns key/value pairs. The key is the module name, the value is the 144version number. If the installed version of the module is at or below the 145specified one then the module will not work. A newer version may work, but is 146not tested or verified. 147 148=back 149 150=head1 SOURCE 151 152The source code repository for Test2 can be found at 153L<https://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 173Copyright 2020 Chad Granum E<lt>exodist@cpan.orgE<gt>. 174 175This program is free software; you can redistribute it and/or 176modify it under the same terms as Perl itself. 177 178See L<https://dev.perl.org/licenses/> 179 180=cut 181