Skip to content

Commit

Permalink
test, doc, make warning if version range and not req EUMM >= 7.11_01
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Mar 20, 2016
1 parent b62ffb3 commit ffdfb87
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 6 deletions.
5 changes: 5 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
7.11_06

Enhancements:
- Warn if use version range but no specify minimum EUMM >= 7.11_01

7.11_05 Sat Mar 19 09:41:02 GMT 2016

Bug fixes:
Expand Down
28 changes: 27 additions & 1 deletion lib/ExtUtils/MakeMaker.pm
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,28 @@ sub _has_cpan_meta_requirements {
};
}

sub _min_EUMM {
my ($self) = @_;
my $cr = ($self->{CONFIGURE_REQUIRES} && $self->{CONFIGURE_REQUIRES}{'ExtUtils::MakeMaker'});
return $cr if $cr;
my @meta_versions = sort grep defined, map {
(exists $_->{prereqs} and
exists $_->{prereqs}{configure} and
exists $_->{prereqs}{configure}{requires})
? $_->{prereqs}{configure}{requires}{'ExtUtils::MakeMaker'}
: ()
} grep $_, @{$self}{qw(META_ADD META_MERGE)};
return 0 unless @meta_versions;
$meta_versions[0] || 0;
}

sub _got_version_ranges {
my ($self) = @_;
my @all_versions = map values %$_, grep defined, @{$self}{@PREREQ_KEYS};
return 0 unless @all_versions;
grep /[^v\d\._]/, @all_versions;
}

sub new {
my($class,$self) = @_;
my($key);
Expand All @@ -447,6 +469,9 @@ sub new {
# Cleanup all the module requirement bits
my %key2cmr;
my $has_cpan_meta_requirements = _has_cpan_meta_requirements;
warn "Warning: version range without prerequisite of EUMM >= 7.11_01"
if $has_cpan_meta_requirements and $self->_min_EUMM < 7.1101
and $self->_got_version_ranges;
for my $key (@PREREQ_KEYS) {
$self->{$key} ||= {};
if ($has_cpan_meta_requirements) {
Expand Down Expand Up @@ -2684,7 +2709,8 @@ A hash of modules that are needed to run your module. The keys are
the module names ie. Test::More, and the minimum version is the
value. If the required version number is 0 any version will do.
The versions given may be a Perl v-string (see L<version>) or a range
(see L<CPAN::Meta::Requirements>).
(see L<CPAN::Meta::Requirements>). If you give a range, you need to
specify a minimum EUMM of at least C<7.11_01> in C<CONFIGURE_REQUIRES>.
This will go into the C<requires> field of your F<META.yml> and the
C<runtime> of the C<prereqs> field of your F<META.json>.
Expand Down
48 changes: 44 additions & 4 deletions t/prereq.t
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ BEGIN {

use strict;
use Config;
use Test::More tests => 21;
use Test::More tests => 24;
use File::Temp qw[tempdir];

use TieOut;
Expand Down Expand Up @@ -57,7 +57,7 @@ ok( chdir 'Big-Dummy', "chdir'd to Big-Dummy" ) ||
is $warnings, '', 'basic prereq';

SKIP: {
skip 'No CMR, no version ranges', 1
skip 'No CMR, no version ranges', 4
unless ExtUtils::MakeMaker::_has_cpan_meta_requirements;
$warnings = '';
WriteMakefile(
Expand All @@ -66,15 +66,55 @@ ok( chdir 'Big-Dummy', "chdir'd to Big-Dummy" ) ||
strict => '>= 0, <= 99999',
}
);
is $warnings, '', 'version range';
isnt $warnings, '', 'version range, no min EUMM specified';

$warnings = '';
WriteMakefile(
NAME => 'Big::Dummy',
PREREQ_PM => {
strict => '>= 0, <= 99999',
},
CONFIGURE_REQUIRES => {
'ExtUtils::MakeMaker' => '7.04',
},
);
isnt $warnings, '', 'version range and insufficient EUMM specified';

$warnings = '';
WriteMakefile(
NAME => 'Big::Dummy',
PREREQ_PM => {
strict => '>= 0, <= 99999',
},
CONFIGURE_REQUIRES => {
'ExtUtils::MakeMaker' => 7.11_01,
},
);
is $warnings, '', 'version range and sufficient EUMM specified';

$warnings = '';
WriteMakefile(
NAME => 'Big::Dummy',
PREREQ_PM => {
strict => '>= 0, <= 99999',
},
META_MERGE => {
prereqs => {
configure => {
requires => { 'ExtUtils::MakeMaker' => 7.1101 },
},
},
},
);
is $warnings, '', 'version range and sufficient EUMM specified meta';
}

$warnings = '';
WriteMakefile(
NAME => 'Big::Dummy',
PREREQ_PM => {
strict => 99999
}
},
);
is $warnings,
sprintf("Warning: prerequisite strict 99999 not found. We have %s.\n",
Expand Down
3 changes: 2 additions & 1 deletion t/vstrings.t
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ sub capture_make {

WriteMakefile(
NAME => 'VString::Test',
PREREQ_PM => { $package , $version }
PREREQ_PM => { $package , $version },
CONFIGURE_REQUIRES => { 'ExtUtils::MakeMaker' => 7.1101 },
);

return $warnings;
Expand Down

0 comments on commit ffdfb87

Please sign in to comment.