diff options
author | Karen Etheridge <ether@cpan.org> | 2019-04-17 19:50:09 -0700 |
---|---|---|
committer | Karen Etheridge <ether@cpan.org> | 2019-04-17 19:50:09 -0700 |
commit | ce054fc59d9a68c982281c7c9f36c3bcc195d62a (patch) | |
tree | 73bf3c037725db276732b86f9eeb98a554d44f16 /cpan/Module-Metadata | |
parent | d493784f6104b2f27789c4c2d36fc84690eaef2d (diff) | |
download | perl-ce054fc59d9a68c982281c7c9f36c3bcc195d62a.tar.gz |
upgrade Module-Metadata to 1.000035
1.000035 2019-04-18 02:43:11Z
- quieten noisy tests (issue #31)
1.000034 2018-07-19 20:26:18Z (TRIAL RELEASE)
- fix how relative paths are absolutized, so they work properly on MSWin32
(Christian Walde, PR#24)
Diffstat (limited to 'cpan/Module-Metadata')
-rw-r--r-- | cpan/Module-Metadata/lib/Module/Metadata.pm | 30 | ||||
-rw-r--r-- | cpan/Module-Metadata/t/encoding.t | 2 | ||||
-rw-r--r-- | cpan/Module-Metadata/t/extract-package.t | 2 | ||||
-rw-r--r-- | cpan/Module-Metadata/t/extract-version.t | 4 | ||||
-rw-r--r-- | cpan/Module-Metadata/t/lib/GeneratePackage.pm | 24 | ||||
-rw-r--r-- | cpan/Module-Metadata/t/metadata.t | 44 |
6 files changed, 56 insertions, 50 deletions
diff --git a/cpan/Module-Metadata/lib/Module/Metadata.pm b/cpan/Module-Metadata/lib/Module/Metadata.pm index 7f49da6d59..593b1c9930 100644 --- a/cpan/Module-Metadata/lib/Module/Metadata.pm +++ b/cpan/Module-Metadata/lib/Module/Metadata.pm @@ -1,6 +1,6 @@ # -*- mode: cperl; tab-width: 8; indent-tabs-mode: nil; basic-offset: 2 -*- # vim:ts=8:sw=2:et:sta:sts=2:tw=78 -package Module::Metadata; # git description: v1.000032-7-gb4e8a3f +package Module::Metadata; # git description: v1.000034-7-gcc9c7d0 # ABSTRACT: Gather package and POD information from perl module files # Adapted from Perl-licensed code originally distributed with @@ -14,7 +14,7 @@ sub __clean_eval { eval $_[0] } use strict; use warnings; -our $VERSION = '1.000033'; +our $VERSION = '1.000035'; use Carp qw/croak/; use File::Spec; @@ -214,7 +214,7 @@ sub new_from_module { unless defined $args{version}; croak "provides() does not support version '$args{version}' metadata" - unless grep { $args{version} eq $_ } qw/1.4 2/; + unless grep $args{version} eq $_, qw/1.4 2/; $args{prefix} = 'lib' unless defined $args{prefix}; @@ -260,8 +260,8 @@ sub new_from_module { # separating into primary & alternative candidates my( %prime, %alt ); foreach my $file (@files) { - my $mapped_filename = File::Spec::Unix->abs2rel( $file, $dir ); - my @path = split( /\//, $mapped_filename ); + my $mapped_filename = File::Spec->abs2rel( $file, $dir ); + my @path = File::Spec->splitdir( $mapped_filename ); (my $prime_package = join( '::', @path )) =~ s/\.pm$//; my $pm_info = $class->new_from_file( $file ); @@ -667,7 +667,7 @@ sub _parse_fh { sub __uniq (@) { my (%seen, $key); - grep { not $seen{ $key = $_ }++ } @_; + grep !$seen{ $key = $_ }++, @_; } { @@ -818,10 +818,10 @@ sub pod { sub is_indexable { my ($self, $package) = @_; - my @indexable_packages = grep { $_ ne 'main' } $self->packages_inside; + my @indexable_packages = grep $_ ne 'main', $self->packages_inside; # check for specific package, if provided - return !! grep { $_ eq $package } @indexable_packages if $package; + return !! grep $_ eq $package, @indexable_packages if $package; # otherwise, check for any indexable packages at all return !! @indexable_packages; @@ -841,7 +841,7 @@ Module::Metadata - Gather package and POD information from perl module files =head1 VERSION -version 1.000033 +version 1.000035 =head1 SYNOPSIS @@ -1070,7 +1070,7 @@ assistance from David Golden (xdg) <dagolden@cpan.org>. =head1 CONTRIBUTORS -=for stopwords Karen Etheridge David Golden Vincent Pit Matt S Trout Chris Nehren Graham Knop Olivier Mengué Tomas Doran Tatsuhiko Miyagawa tokuhirom Kent Fredric Peter Rabbitson Steve Hay Jerry D. Hedden Craig A. Berry Mitchell Steinbrunner Edward Zborowski Gareth Harper James Raspass 'BinGOs' Williams Josh Jore +=for stopwords Karen Etheridge David Golden Vincent Pit Matt S Trout Chris Nehren Graham Knop Olivier Mengué Tomas Doran tokuhirom Christian Walde Tatsuhiko Miyagawa Peter Rabbitson Steve Hay Jerry D. Hedden Craig A. Berry Mitchell Steinbrunner Edward Zborowski Gareth Harper James Raspass 'BinGOs' Williams Josh Jore Kent Fredric =over 4 @@ -1108,15 +1108,15 @@ Tomas Doran <bobtfish@bobtfish.net> =item * -Tatsuhiko Miyagawa <miyagawa@bulknews.net> +tokuhirom <tokuhirom@gmail.com> =item * -tokuhirom <tokuhirom@gmail.com> +Christian Walde <walde.christian@googlemail.com> =item * -Kent Fredric <kentnl@cpan.org> +Tatsuhiko Miyagawa <miyagawa@bulknews.net> =item * @@ -1166,6 +1166,10 @@ Chris 'BinGOs' Williams <chris@bingosnet.co.uk> Josh Jore <jjore@cpan.org> +=item * + +Kent Fredric <kentnl@cpan.org> + =back =head1 COPYRIGHT & LICENSE diff --git a/cpan/Module-Metadata/t/encoding.t b/cpan/Module-Metadata/t/encoding.t index 932614fff2..a7d0e46458 100644 --- a/cpan/Module-Metadata/t/encoding.t +++ b/cpan/Module-Metadata/t/encoding.t @@ -1,5 +1,3 @@ -#!perl - use strict; use warnings; use File::Spec; diff --git a/cpan/Module-Metadata/t/extract-package.t b/cpan/Module-Metadata/t/extract-package.t index 44f4de9b21..143372af88 100644 --- a/cpan/Module-Metadata/t/extract-package.t +++ b/cpan/Module-Metadata/t/extract-package.t @@ -2,7 +2,7 @@ use strict; use warnings; # vim:ts=8:sw=2:et:sta:sts=2 -use Test::More 0.82; +use Test::More 0.88; use Module::Metadata; use lib 't/lib'; diff --git a/cpan/Module-Metadata/t/extract-version.t b/cpan/Module-Metadata/t/extract-version.t index 1a49be1a12..dea690b4d3 100644 --- a/cpan/Module-Metadata/t/extract-version.t +++ b/cpan/Module-Metadata/t/extract-version.t @@ -2,7 +2,7 @@ use strict; use warnings; # vim:ts=8:sw=2:et:sta:sts=2 -use Test::More 0.82; +use Test::More 0.88; use Module::Metadata; use lib 't/lib'; @@ -648,7 +648,7 @@ foreach my $test_case (@modules) { # We want to ensure we preserve the original, as long as it's legal, so we # explicitly check the stringified form. { - local $TODO = !defined($got) && ($test_case->{TODO_code_sub} || $test_case->{TODO_scalar}); + local $TODO = !defined($got) && ($test_case->{TODO_code_sub} || $test_case->{TODO_scalar}) ? 1 : undef; isa_ok($got, 'version') or $errs++ if defined $expected_version; } diff --git a/cpan/Module-Metadata/t/lib/GeneratePackage.pm b/cpan/Module-Metadata/t/lib/GeneratePackage.pm index 07c92d3713..dd48aab5fd 100644 --- a/cpan/Module-Metadata/t/lib/GeneratePackage.pm +++ b/cpan/Module-Metadata/t/lib/GeneratePackage.pm @@ -3,7 +3,7 @@ use warnings; package GeneratePackage; # vim:ts=8:sw=2:et:sta:sts=2 -use base 'Exporter'; +our @ISA = ('Exporter'); our @EXPORT = qw(tmpdir generate_file); use Cwd; @@ -12,14 +12,24 @@ use File::Path; use File::Temp; use IO::File; +BEGIN { + my $cwd = File::Spec->rel2abs(Cwd::cwd); + sub _original_cwd { return $cwd } +} + sub tmpdir { + my (@args) = @_; File::Temp::tempdir( 'MMD-XXXXXXXX', - CLEANUP => 1, - DIR => ($ENV{PERL_CORE} ? File::Spec->rel2abs(Cwd::cwd) : File::Spec->tmpdir), + CLEANUP => 0, + DIR => ($ENV{PERL_CORE} ? _original_cwd : File::Spec->tmpdir), + @args, ); } +my $tmp; +BEGIN { $tmp = tmpdir; Test::More::note "using temp dir $tmp"; } + sub generate_file { my ($dir, $rel_filename, $content) = @_; @@ -35,4 +45,12 @@ sub generate_file { return $abs_filename; } +END { + die "tests failed; leaving temp dir $tmp behind" + if $ENV{AUTHOR_TESTING} and not Test::Builder->new->is_passing; + Test::More::note "removing temp dir $tmp"; + chdir _original_cwd; + File::Path::rmtree($tmp); +} + 1; diff --git a/cpan/Module-Metadata/t/metadata.t b/cpan/Module-Metadata/t/metadata.t index 5dee700bbc..fc9bd59441 100644 --- a/cpan/Module-Metadata/t/metadata.t +++ b/cpan/Module-Metadata/t/metadata.t @@ -11,7 +11,12 @@ use File::Basename; use Cwd (); use File::Path; -plan tests => 70; +use lib 't/lib'; +use GeneratePackage; + +my $tmpdir = GeneratePackage::tmpdir(); + +plan tests => 71; require_ok('Module::Metadata'); @@ -24,29 +29,6 @@ require_ok('Module::Metadata'); ######################### -BEGIN { - my $cwd = File::Spec->rel2abs(Cwd::cwd); - sub original_cwd { return $cwd } -} - -# Set up a temp directory -sub tmpdir { - my (@args) = @_; - my $dir = $ENV{PERL_CORE} ? original_cwd : File::Spec->tmpdir; - return File::Temp::tempdir('MMD-XXXXXXXX', CLEANUP => 0, DIR => $dir, @args); -} - -my $tmp; -BEGIN { $tmp = tmpdir; note "using temp dir $tmp"; } - -END { - die "tests failed; leaving temp dir $tmp behind" - if $ENV{AUTHOR_TESTING} and not Test::Builder->new->is_passing; - note "removing temp dir $tmp"; - chdir original_cwd; - File::Path::rmtree($tmp); -} - # generates a new distribution: # files => { relative filename => $content ... } # returns the name of the distribution (not including version), @@ -57,7 +39,7 @@ END { my %opts = @_; my $distname = 'Simple' . $test_num++; - my $distdir = File::Spec->catdir($tmp, $distname); + my $distdir = File::Spec->catdir($tmpdir, $distname); note "using dist $distname in $distdir"; File::Path::mkpath($distdir) or die "failed to create '$distdir'"; @@ -328,11 +310,8 @@ our $VERSION = '1.23'; is( $pm_info->version, '1.23', 'version for default package' ); } -my $tmpdir = GeneratePackage::tmpdir(); my $undef; my $test_num = 0; -use lib 't/lib'; -use GeneratePackage; { # and now a real pod file @@ -453,11 +432,18 @@ Simple Simon } }; - my $got_pvfd = Module::Metadata->package_versions_from_directory('lib'); + my $dir = "lib"; + my $got_pvfd = Module::Metadata->package_versions_from_directory($dir); is_deeply( $got_pvfd, $exp_pvfd, "package_version_from_directory()" ) or diag explain $got_pvfd; + my $absolute_file = File::Spec->rel2abs($exp_pvfd->{Simple}{file}, $dir); + my $got_pvfd2 = Module::Metadata->package_versions_from_directory($dir, [$absolute_file]); + + is_deeply( $got_pvfd2, $exp_pvfd, "package_version_from_directory() with provided absolute file path" ) + or diag explain $got_pvfd; + { my $got_provides = Module::Metadata->provides(dir => 'lib', version => 2); my $exp_provides = { |