Skip Menu |

This queue is for tickets about the Module-Metadata CPAN distribution.

Maintainer(s)' notes

Attention bug reporters: issues MUST include the version of Module::Metadata that you are running that exhibit the stated symptoms. thank you!

Report information
The Basics
Id: 92640
Status: open
Priority: 0/
Queue: Module-Metadata

People
Owner: ether [...] cpan.org
Requestors: KENTNL [...] cpan.org
RWSTAUNER [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 1.000011
Fixed in: (no value)



Subject: provides() doesn't work with 'files' arg
I was looking at the code and noticed that when provides() doesn't have a 'dir' arg it assumes 'files', but when it delegates to package_versions_from_directory() it doesn't pass the necessary $dir arg, so it errors: Module::Metadata->provides(version => 2, files => ["lib/Simple.pm"]) Can't stat ARRAY(0x1325c68): No such file or directory I confirmed with a test case (patch attached). Since the dir arg (which provides() doesn't know) is used in abs2rel() I'm not sure if '.' is a sensible default or not... I haven't really thought through the use cases. I did have to pass a 'prefix' in the test case to make it make sense, but again I haven't really thought through the use cases, I just knew the method didn't work as it was. Adjust the patch or refine the docs or whatever as you see fit.
Subject: provides-files-test.patch
diff --git a/lib/Module/Metadata.pm b/lib/Module/Metadata.pm index d11c8c0..077fbdc 100644 --- a/lib/Module/Metadata.pm +++ b/lib/Module/Metadata.pm @@ -213,7 +213,9 @@ sub new_from_module { else { croak "provides() requires 'files' to be an array reference\n" unless ref $args{files} eq 'ARRAY'; - $p = $class->package_versions_from_directory($args{files}); + # The $dir arg won't be used for find() but will be used for abs2rel(). + # FIXME: What should it be? + $p = $class->package_versions_from_directory('.', $args{files}); } # Now, fix up files with prefix diff --git a/t/metadata.t b/t/metadata.t index 38649bd..32ce35a 100644 --- a/t/metadata.t +++ b/t/metadata.t @@ -260,7 +260,7 @@ package Simple-Edward; ); my %pkg_names = reverse @pkg_names; -plan tests => 63 + (2 * keys( %modules )) + (2 * keys( %pkg_names )); +plan tests => 64 + (2 * keys( %modules )) + (2 * keys( %pkg_names )); require_ok('Module::Metadata'); @@ -712,6 +712,23 @@ is_deeply( $got_pvfd, $exp_pvfd, "package_version_from_directory()" ) or diag explain $got_provides; } +{ + my $got_provides = Module::Metadata->provides(files => ['lib/Simple.pm'], prefix => '', version => 1.4); + my $exp_provides = { + 'Simple' => { + 'file' => 'lib/Simple.pm', + 'version' => '0.01' + }, + 'Simple::Ex' => { + 'file' => 'lib/Simple.pm', + 'version' => '0.02' + } + }; + + is_deeply( $got_provides, $exp_provides, "provides(file => [...])" ) + or diag explain $got_provides; +} + # Check package_versions_from_directory with regard to case-sensitivity { $dist->change_file( 'lib/Simple.pm', <<'---' );
Subject: Re: [rt.cpan.org #92640] provides() doesn't work with 'files' arg
Date: Sat, 1 Feb 2014 10:19:28 -0800
To: Randy Stauner via RT <bug-Module-Metadata [...] rt.cpan.org>
From: Karen Etheridge <ether [...] cpan.org>
On Sat, Feb 01, 2014 at 10:26:16AM -0500, Randy Stauner via RT wrote: Show quoted text
> I was looking at the code and noticed that when provides() doesn't have a 'dir' arg it assumes 'files', but when it delegates to package_versions_from_directory() it doesn't pass the necessary $dir arg, so it errors:
Yeah, that problem has been on my radar for a while... the whole API in this area is a mess and needs to be torn out. Too many assumptions are made, and there is no test coverage for this either. Thanks for the patch; I will take a look shortly when I come back to this module!

Still here in 1.000031-TRIAL

perl -d:Confess -MModule::Metadata -e' Module::Metadata->provides( version => 2, files => [] )'
Can't stat ARRAY(0x18364c0): No such file or directory
 at /home/kent/perl5/perlbrew/perls/5.22.1-nossp-sdbm-nopmc/lib/5.22.1/File/Find.pm line 230.
    File::Find::_find_opt(HASH(0x184a9e0), ARRAY(0x18364c0)) called at /home/kent/perl5/perlbrew/perls/5.22.1-nossp-sdbm-nopmc/lib/5.22.1/File/Find.pm line 759
    File::Find::find(HASH(0x184a9e0), ARRAY(0x18364c0)) called at /home/kent/perl5/perlbrew/perls/5.22.1-nossp-sdbm-nopmc/lib/site_perl/5.22.1/Module/Metadata.pm line 255
    Module::Metadata::package_versions_from_directory("Module::Metadata", ARRAY(0x18364c0)) called at /home/kent/perl5/perlbrew/perls/5.22.1-nossp-sdbm-nopmc/lib/site_perl/5.22.1/Module/Metadata.pm line 228
    Module::Metadata::provides("Module::Metadata", "version", 2, "files", ARRAY(0x18364c0)) called at -e line 1