Skip to content

Commit ffdfb87

Browse files
committed
test, doc, make warning if version range and not req EUMM >= 7.11_01
1 parent b62ffb3 commit ffdfb87

File tree

4 files changed

+78
-6
lines changed

4 files changed

+78
-6
lines changed

Changes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
7.11_06
2+
3+
Enhancements:
4+
- Warn if use version range but no specify minimum EUMM >= 7.11_01
5+
16
7.11_05 Sat Mar 19 09:41:02 GMT 2016
27

38
Bug fixes:

lib/ExtUtils/MakeMaker.pm

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,28 @@ sub _has_cpan_meta_requirements {
427427
};
428428
}
429429

430+
sub _min_EUMM {
431+
my ($self) = @_;
432+
my $cr = ($self->{CONFIGURE_REQUIRES} && $self->{CONFIGURE_REQUIRES}{'ExtUtils::MakeMaker'});
433+
return $cr if $cr;
434+
my @meta_versions = sort grep defined, map {
435+
(exists $_->{prereqs} and
436+
exists $_->{prereqs}{configure} and
437+
exists $_->{prereqs}{configure}{requires})
438+
? $_->{prereqs}{configure}{requires}{'ExtUtils::MakeMaker'}
439+
: ()
440+
} grep $_, @{$self}{qw(META_ADD META_MERGE)};
441+
return 0 unless @meta_versions;
442+
$meta_versions[0] || 0;
443+
}
444+
445+
sub _got_version_ranges {
446+
my ($self) = @_;
447+
my @all_versions = map values %$_, grep defined, @{$self}{@PREREQ_KEYS};
448+
return 0 unless @all_versions;
449+
grep /[^v\d\._]/, @all_versions;
450+
}
451+
430452
sub new {
431453
my($class,$self) = @_;
432454
my($key);
@@ -447,6 +469,9 @@ sub new {
447469
# Cleanup all the module requirement bits
448470
my %key2cmr;
449471
my $has_cpan_meta_requirements = _has_cpan_meta_requirements;
472+
warn "Warning: version range without prerequisite of EUMM >= 7.11_01"
473+
if $has_cpan_meta_requirements and $self->_min_EUMM < 7.1101
474+
and $self->_got_version_ranges;
450475
for my $key (@PREREQ_KEYS) {
451476
$self->{$key} ||= {};
452477
if ($has_cpan_meta_requirements) {
@@ -2684,7 +2709,8 @@ A hash of modules that are needed to run your module. The keys are
26842709
the module names ie. Test::More, and the minimum version is the
26852710
value. If the required version number is 0 any version will do.
26862711
The versions given may be a Perl v-string (see L<version>) or a range
2687-
(see L<CPAN::Meta::Requirements>).
2712+
(see L<CPAN::Meta::Requirements>). If you give a range, you need to
2713+
specify a minimum EUMM of at least C<7.11_01> in C<CONFIGURE_REQUIRES>.
26882714
26892715
This will go into the C<requires> field of your F<META.yml> and the
26902716
C<runtime> of the C<prereqs> field of your F<META.json>.

t/prereq.t

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ BEGIN {
99

1010
use strict;
1111
use Config;
12-
use Test::More tests => 21;
12+
use Test::More tests => 24;
1313
use File::Temp qw[tempdir];
1414

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

5959
SKIP: {
60-
skip 'No CMR, no version ranges', 1
60+
skip 'No CMR, no version ranges', 4
6161
unless ExtUtils::MakeMaker::_has_cpan_meta_requirements;
6262
$warnings = '';
6363
WriteMakefile(
@@ -66,15 +66,55 @@ ok( chdir 'Big-Dummy', "chdir'd to Big-Dummy" ) ||
6666
strict => '>= 0, <= 99999',
6767
}
6868
);
69-
is $warnings, '', 'version range';
69+
isnt $warnings, '', 'version range, no min EUMM specified';
70+
71+
$warnings = '';
72+
WriteMakefile(
73+
NAME => 'Big::Dummy',
74+
PREREQ_PM => {
75+
strict => '>= 0, <= 99999',
76+
},
77+
CONFIGURE_REQUIRES => {
78+
'ExtUtils::MakeMaker' => '7.04',
79+
},
80+
);
81+
isnt $warnings, '', 'version range and insufficient EUMM specified';
82+
83+
$warnings = '';
84+
WriteMakefile(
85+
NAME => 'Big::Dummy',
86+
PREREQ_PM => {
87+
strict => '>= 0, <= 99999',
88+
},
89+
CONFIGURE_REQUIRES => {
90+
'ExtUtils::MakeMaker' => 7.11_01,
91+
},
92+
);
93+
is $warnings, '', 'version range and sufficient EUMM specified';
94+
95+
$warnings = '';
96+
WriteMakefile(
97+
NAME => 'Big::Dummy',
98+
PREREQ_PM => {
99+
strict => '>= 0, <= 99999',
100+
},
101+
META_MERGE => {
102+
prereqs => {
103+
configure => {
104+
requires => { 'ExtUtils::MakeMaker' => 7.1101 },
105+
},
106+
},
107+
},
108+
);
109+
is $warnings, '', 'version range and sufficient EUMM specified meta';
70110
}
71111

72112
$warnings = '';
73113
WriteMakefile(
74114
NAME => 'Big::Dummy',
75115
PREREQ_PM => {
76116
strict => 99999
77-
}
117+
},
78118
);
79119
is $warnings,
80120
sprintf("Warning: prerequisite strict 99999 not found. We have %s.\n",

t/vstrings.t

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ sub capture_make {
7575

7676
WriteMakefile(
7777
NAME => 'VString::Test',
78-
PREREQ_PM => { $package , $version }
78+
PREREQ_PM => { $package , $version },
79+
CONFIGURE_REQUIRES => { 'ExtUtils::MakeMaker' => 7.1101 },
7980
);
8081

8182
return $warnings;

0 commit comments

Comments
 (0)