diff options
author | Chris 'BinGOs' Williams <chris@bingosnet.co.uk> | 2015-01-04 19:09:11 +0000 |
---|---|---|
committer | Chris 'BinGOs' Williams <chris@bingosnet.co.uk> | 2015-01-04 19:09:11 +0000 |
commit | adc2cdfb25be1eb14544e149b2dfb199dcbbc06e (patch) | |
tree | 7e52f47d32c746f3c295a3ddf6d6a1160e816429 /cpan/Module-Metadata | |
parent | 631d564d55844d5113b56f53d7c2270cd0e6ef25 (diff) | |
download | perl-adc2cdfb25be1eb14544e149b2dfb199dcbbc06e.tar.gz |
Update Module-Metadata to CPAN version 1.000025
[DELTA]
1.000025 2015-01-04 18:56:00Z
- evaluate version assignment in a clean environment, to fix assignment in a
block (RT#101095)
Diffstat (limited to 'cpan/Module-Metadata')
-rw-r--r-- | cpan/Module-Metadata/lib/Module/Metadata.pm | 41 | ||||
-rw-r--r-- | cpan/Module-Metadata/t/contains_pod.t | 2 | ||||
-rw-r--r-- | cpan/Module-Metadata/t/metadata.t | 18 | ||||
-rw-r--r-- | cpan/Module-Metadata/t/version.t | 9 |
4 files changed, 40 insertions, 30 deletions
diff --git a/cpan/Module-Metadata/lib/Module/Metadata.pm b/cpan/Module-Metadata/lib/Module/Metadata.pm index a5d0fbaef3..dddfedbe27 100644 --- a/cpan/Module-Metadata/lib/Module/Metadata.pm +++ b/cpan/Module-Metadata/lib/Module/Metadata.pm @@ -1,11 +1,6 @@ # -*- mode: cperl; tab-width: 8; indent-tabs-mode: nil; basic-offset: 2 -*- # vim:ts=8:sw=2:et:sta:sts=2 -package Module::Metadata; -BEGIN { - $Module::Metadata::AUTHORITY = 'cpan:MSTROUT'; -} -# git description: v1.000023-1-g6bfd8b6 -$Module::Metadata::VERSION = '1.000024'; +package Module::Metadata; # git description: v1.000024-12-g978f25c # Adapted from Perl-licensed code originally distributed with # Module-Build by Ken Williams @@ -14,9 +9,12 @@ $Module::Metadata::VERSION = '1.000024'; # perl modules (assuming this may be expanded in the distant # parrot future to look at other types of modules). +sub __clean_eval { eval $_[0] } use strict; use warnings; +our $VERSION = '1.000025'; + use Carp qw/croak/; use File::Spec; BEGIN { @@ -642,41 +640,36 @@ sub _evaluate_version_line { my $self = shift; my( $sigil, $variable_name, $line ) = @_; - # Some of this code came from the ExtUtils:: hierarchy. - - # We compile into $vsub because 'use version' would cause + # We compile into a local sub because 'use version' would cause # compiletime/runtime issues with local() - my $vsub; $pn++; # everybody gets their own package - my $eval = qq{BEGIN { my \$dummy = q# Hide from _packages_inside() - #; package Module::Metadata::_version::p$pn; + my $eval = qq{ my \$dummy = q# Hide from _packages_inside() + #; package Module::Metadata::_version::p${pn}; use version; - no strict; - no warnings; - - \$vsub = sub { - local $sigil$variable_name; - \$$variable_name=undef; - $line; - \$$variable_name - }; - }}; + sub { + local $sigil$variable_name; + $line; + \$$variable_name + }; + }; $eval = $1 if $eval =~ m{^(.+)}s; local $^W; # Try to get the $VERSION - eval $eval; + my $vsub = __clean_eval($eval); # some modules say $VERSION <equal sign> $Foo::Bar::VERSION, but Foo::Bar isn't # installed, so we need to hunt in ./lib for it if ( $@ =~ /Can't locate/ && -d 'lib' ) { local @INC = ('lib',@INC); - eval $eval; + $vsub = __clean_eval($eval); } warn "Error evaling version line '$eval' in $self->{filename}: $@\n" if $@; + (ref($vsub) eq 'CODE') or croak "failed to build version sub for $self->{filename}"; + my $result = eval { $vsub->() }; # FIXME: $eval is not the right thing to print here croak "Could not get version from $self->{filename} by executing:\n$eval\n\nThe fatal error was: $@\n" diff --git a/cpan/Module-Metadata/t/contains_pod.t b/cpan/Module-Metadata/t/contains_pod.t index 52971232b3..016e7844ad 100644 --- a/cpan/Module-Metadata/t/contains_pod.t +++ b/cpan/Module-Metadata/t/contains_pod.t @@ -8,7 +8,7 @@ BEGIN { ? require IO::Scalar && sub ($) { IO::Scalar->new(\$_[0]); } - # hide in n eval'd string so Perl::MinimumVersion doesn't clutch its pearls + # hide in an eval'd string so Perl::MinimumVersion doesn't clutch its pearls : eval <<'EVAL' sub ($) { open my $fh, '<', \$_[0]; diff --git a/cpan/Module-Metadata/t/metadata.t b/cpan/Module-Metadata/t/metadata.t index 0a066fcf26..3d55111e3e 100644 --- a/cpan/Module-Metadata/t/metadata.t +++ b/cpan/Module-Metadata/t/metadata.t @@ -221,6 +221,22 @@ package Simple; our ($VERSION) = ($CVSVERSION =~ /(\d+\.\d+)/); } --- + 'v2.2.102.2' => <<'---', # our + bare v-string +package Simple; +our $VERSION = v2.2.102.2; +--- + '0.0.9_1' => <<'---', # our + dev release +package Simple; +our $VERSION = "0.0.9_1"; +--- + '1.12' => <<'---', # our + crazy string and substitution code +package Simple; +our $VERSION = '1.12.B55J2qn'; our $WTF = $VERSION; $WTF =~ s/^\d+\.\d+\.//; # attempts to rationalize $WTF go here. +--- + '1.12' => <<'---', # our in braces, as in Dist::Zilla::Plugin::PkgVersion with use_our = 1 +package Simple; +{ our $VERSION = '1.12'; } +--- ); # format: expected package name => code snippet @@ -284,7 +300,7 @@ BEGIN { sub original_cwd { return $cwd } } -# Setup a temp directory +# Set up a temp directory sub tmpdir { my (@args) = @_; my $dir = $ENV{PERL_CORE} ? original_cwd : File::Spec->tmpdir; diff --git a/cpan/Module-Metadata/t/version.t b/cpan/Module-Metadata/t/version.t index e523f97a0f..f97a19d1cb 100644 --- a/cpan/Module-Metadata/t/version.t +++ b/cpan/Module-Metadata/t/version.t @@ -7,14 +7,15 @@ use lib "t/lib/0_2"; plan tests => 4; require Foo; -is $Foo::VERSION, 0.2; +is($Foo::VERSION, 0.2, 'affirmed version of loaded module'); my $meta = Module::Metadata->new_from_module("Foo", inc => [ "t/lib/0_1" ] ); -is $meta->version, 0.1; +is($meta->version, 0.1, 'extracted proper version from scanned module'); -is $Foo::VERSION, 0.2; +is($Foo::VERSION, 0.2, 'loaded module still retains its version'); -ok eval "use Foo 0.2; 1"; +ok(eval "use Foo 0.2; 1", 'successfully loaded module again') + or diag 'got exception: ', $@; |