| 1 | package Test2::API::Breakage; | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | |||
| 5 | our $VERSION = '1.302073'; | ||
| 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__ |