diff options
Diffstat (limited to 'lib/Dist/CheckConflicts.pm')
-rw-r--r-- | lib/Dist/CheckConflicts.pm | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/Dist/CheckConflicts.pm b/lib/Dist/CheckConflicts.pm index 1fea9e2..393e586 100644 --- a/lib/Dist/CheckConflicts.pm +++ b/lib/Dist/CheckConflicts.pm @@ -11,6 +11,8 @@ our @EXPORT = our @EXPORT_OK = ( use Carp; use List::MoreUtils 0.12 'first_index'; +use Class::Load 'try_load_class'; +use Module::Runtime 'module_notional_filename'; =head1 SYNOPSIS @@ -131,7 +133,7 @@ sub import { for my $conflict (keys %conflicts) { (my $file = $conflict) =~ s{::}{/}g; $file .= '.pm'; - if (exists $INC{$file}) { + if (exists $INC{module_notional_filename($conflict)}) { _check_version([$for], $conflict); } } @@ -266,18 +268,20 @@ sub calculate_conflicts { my @ret; + CONFLICT: for my $conflict (keys %conflicts) { - { - local $SIG{__WARN__} = sub { }; - eval "require $conflict; 1" or next CONFLICT; - } - my $installed = $conflict->VERSION; + my ($success, $error) = try_load_class($conflict); + my $file = module_notional_filename($conflict); + next if not $success and $error =~ /Can't locate \Q$file\E in \@INC/; + + warn "Warning: $conflict did not compile" if not $success; + my $installed = $success ? $conflict->VERSION : 'unknown'; push @ret, { package => $conflict, installed => $installed, required => $conflicts{$conflict}, - } if $installed le $conflicts{$conflict}; + } if not $success or $installed le $conflicts{$conflict}; } return sort { $a->{package} cmp $b->{package} } @ret; |