Skip to content

Commit

Permalink
Build results of 2a9e822 (on future-2.002002)
Browse files Browse the repository at this point in the history
  • Loading branch information
kentfredric committed Jul 7, 2016
1 parent ad5f72e commit 433f1f8
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Changes
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
Revision history for Dist-Zilla-Plugin-MetaProvides

2.002002 2016-07-07T11:48:15Z adb8718
2.002002 2016-07-07T11:55:30Z 2a9e822
- Adds logging warnings for Provides entries that don't map to shipped files. This should not be a problem for anyone
unless you're using custom MetaProvides.
- Warn about cuckooed packages at the "provides-to-dzil" level. This enables automatic exposure of all packages where
"$filename" !~ "/Module/Name.pm" as being potentially problematic.

[Dependencies::Stats]
- Dependencies changed since 2.002001, see misc/*.deps* for details
Expand Down
1 change: 1 addition & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ t/01-Provider/02-resolve-versions.t
t/01-Provider/03-metanoindex.t
t/01-Provider/04-integration.t
t/01-Provider/05-filenames.t
t/01-Provider/06-cuckoo.t
t/02-MetaProvides-ProvideRecord.t
t/03-Types.t
t/04-MetaProvides.t
Expand Down
12 changes: 12 additions & 0 deletions lib/Dist/Zilla/Role/MetaProvider/Provider.pm
Original file line number Diff line number Diff line change
Expand Up @@ -276,15 +276,23 @@ sub metadata {
my $discover = {};
my (%all_filenames) = map { $_->name => 1 } @{ $self->zilla->files || [] };
my (%missing_files);
my (%unmapped_modules);

for my $provide_record ( $self->provides ) {
my $file = $provide_record->file;
my $module = $provide_record->module;

if ( not exists $all_filenames{$file} ) {
$missing_files{$file} = 1;
$self->log_debug( 'Provides entry states missing file <' . $file . '>' );
}

my $notional_filename = do { ( join q[/], split /::|'/sx, $module ) . '.pm' };
if ( $file !~ /\b\Q$notional_filename\E\z/sx ) {
$unmapped_modules{$module} = 1;
$self->log_debug( 'Provides entry for module <' . $module . '> mapped to problematic <' . $file . '> ( want: <.*/' . $notional_filename . '> )' );
}
$provide_record->copy_into($discover);
}
Expand All @@ -293,6 +301,10 @@ sub metadata {
$self->log( "$nkeys provide map entries did not map to distfiles: " . join q[, ],
sort keys %missing_files );
}
if ( my $nkeys = scalar keys %unmapped_modules ) {
$self->log( "$nkeys provide map entries did not map to .pm files and may not be loadable at install time: " . join q[, ],
sort keys %unmapped_modules );
}
return { provides => $discover };
}
Expand Down
75 changes: 75 additions & 0 deletions t/01-Provider/06-cuckoo.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@

use strict;
use warnings;

use Test::More 0.96;
use Test::Fatal;
use Path::Tiny qw( path );
use Test::DZil qw( simple_ini Builder );

{
package # PAUSE
Dist::Zilla::Plugin::FakePlugin;

use Moose;
use Dist::Zilla::MetaProvides::ProvideRecord;

with 'Dist::Zilla::Role::Plugin';
with 'Dist::Zilla::Role::MetaProvider::Provider';

sub provides {
my $self = shift;
return $self->_apply_meta_noindex(
Dist::Zilla::MetaProvides::ProvideRecord->new(
module => 'FakeModule',
file => 'C:\temp\notevenonwindows.pl',
version => '3.1414',
parent => $self,
),
Dist::Zilla::MetaProvides::ProvideRecord->new(
module => 'Example',
file => 'lib/Example.pm',
version => '3.1414',
parent => $self,
),
Dist::Zilla::MetaProvides::ProvideRecord->new(
module => 'Example::Hidden',
file => 'lib/Example.pm',
version => '3.1414',
parent => $self,
),

);
}

__PACKAGE__->meta->make_immutable;
$INC{'Dist/Zilla/Plugin/FakePlugin.pm'} = 1;
}

my $test_module = <<'EOF';
package Example;
1;
EOF

my $builder = Builder->from_config(
{
dist_root => 'invalid',
},
{
add_files => {
path('source/dist.ini') => simple_ini( 'GatherDir', [ 'FakePlugin' => { meta_noindex => 1 } ] ),
path('source/lib/Example.pm') => $test_module,
},
},
);

$builder->chrome->logger->set_debug(1);
$builder->build;

ok( ( grep { /for module <Fake/ } @{ $builder->log_messages } ), "Fake namespace without matching file warned" );
ok( !( grep { /for module <Example>/ } @{ $builder->log_messages } ), "Example with matching file doesnt warn" );
ok( ( grep { /for module <Example::Hidden>/ } @{ $builder->log_messages } ), "Example::Hidden cuckoo warns" );

note explain $builder->log_messages;
done_testing;
1 change: 1 addition & 0 deletions xt/author/eol.t
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ my @files = (
't/01-Provider/03-metanoindex.t',
't/01-Provider/04-integration.t',
't/01-Provider/05-filenames.t',
't/01-Provider/06-cuckoo.t',
't/02-MetaProvides-ProvideRecord.t',
't/03-Types.t',
't/04-MetaProvides.t',
Expand Down

0 comments on commit 433f1f8

Please sign in to comment.