From ffdfb8761d2cbecc744d178fb3caf11abf717e09 Mon Sep 17 00:00:00 2001 From: Ed J <mohawk2@users.noreply.github.com> Date: Sat, 19 Mar 2016 20:28:46 +0000 Subject: [PATCH] test, doc, make warning if version range and not req EUMM >= 7.11_01 --- Changes | 5 ++++ lib/ExtUtils/MakeMaker.pm | 28 ++++++++++++++++++++++- t/prereq.t | 48 +++++++++++++++++++++++++++++++++++---- t/vstrings.t | 3 ++- 4 files changed, 78 insertions(+), 6 deletions(-) diff --git a/Changes b/Changes index 19c52fc06..209d6d263 100644 --- a/Changes +++ b/Changes @@ -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: diff --git a/lib/ExtUtils/MakeMaker.pm b/lib/ExtUtils/MakeMaker.pm index ff45fde73..457129693 100644 --- a/lib/ExtUtils/MakeMaker.pm +++ b/lib/ExtUtils/MakeMaker.pm @@ -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); @@ -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) { @@ -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>. diff --git a/t/prereq.t b/t/prereq.t index a01ff2bba..35521f70a 100644 --- a/t/prereq.t +++ b/t/prereq.t @@ -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; @@ -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( @@ -66,7 +66,47 @@ 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 = ''; @@ -74,7 +114,7 @@ ok( chdir 'Big-Dummy', "chdir'd to Big-Dummy" ) || NAME => 'Big::Dummy', PREREQ_PM => { strict => 99999 - } + }, ); is $warnings, sprintf("Warning: prerequisite strict 99999 not found. We have %s.\n", diff --git a/t/vstrings.t b/t/vstrings.t index 808893687..4be56fb62 100644 --- a/t/vstrings.t +++ b/t/vstrings.t @@ -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;