Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Future 2.002002 #6

Merged
merged 3 commits into from
Jul 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Revision history for {{$dist->name}}

{{$NEXT}}
- 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
- test: +1

2.002001 2016-06-29T06:09:34Z 2be5312
- Remove usage of ConfigDumper and inline dump_config code instead.
Expand Down
2 changes: 2 additions & 0 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ my %WriteMakefileArgs = (
"warnings" => 0
},
"TEST_REQUIRES" => {
"Dist::Zilla::Role::Plugin" => 0,
"ExtUtils::MakeMaker" => 0,
"File::Spec" => 0,
"Path::Tiny" => 0,
Expand All @@ -48,6 +49,7 @@ my %WriteMakefileArgs = (
my %FallbackPrereqs = (
"Carp" => 0,
"Dist::Zilla::Role::MetaProvider" => 0,
"Dist::Zilla::Role::Plugin" => 0,
"ExtUtils::MakeMaker" => 0,
"File::Spec" => 0,
"Hash::Merge::Simple" => 0,
Expand Down
36 changes: 32 additions & 4 deletions lib/Dist/Zilla/Role/MetaProvider/Provider.pm
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,38 @@ results returned from C<$self-E<gt>provides>.
=cut

sub metadata {
my ($self) = @_;
my $discover = {};
for ( $self->provides ) {
$_->copy_into($discover);
my ($self) = @_;
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);
}

## no critic (RestrictLongStrings)
if ( my $nkeys = scalar keys %missing_files ) {
$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
2 changes: 2 additions & 0 deletions misc/Changes.deps
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
This file contains changes in REQUIRED dependencies for standard CPAN phases (configure/build/runtime/test)

2.002002
[Added / test requires]
- Dist::Zilla::Role::Plugin

2.002001 2016-06-29T06:09:34Z
[Added / test requires]
Expand Down
2 changes: 2 additions & 0 deletions misc/Changes.deps.all
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
This file contains ALL changes in dependencies in both REQUIRED / OPTIONAL dependencies for all phases (configure/build/runtime/test/develop)

2.002002
[Added / test requires]
- Dist::Zilla::Role::Plugin

2.002001 2016-06-29T06:09:34Z
[Added / test recommends]
Expand Down
10 changes: 5 additions & 5 deletions perlcritic.rc
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ allowed_pragmata = diagnostics feature perlversion strict warnings utf8

[RegularExpressions::RequireExtendedFormatting]

[RegularExpressions::RequireLineBoundaryMatching]
[-RegularExpressions::RequireLineBoundaryMatching]

[Subroutines::ProhibitAmpersandSigils]

Expand All @@ -318,7 +318,7 @@ exempt_subs = MooseX::Types::subtype MooseX::Types::where MooseX::Types::as Moos

[Subroutines::ProhibitExcessComplexity]

[Subroutines::ProhibitExplicitReturnUndef]
[-Subroutines::ProhibitExplicitReturnUndef]

[Subroutines::ProhibitExportingUndeclaredSubs]

Expand All @@ -337,9 +337,9 @@ private_name_regex = _(?!build_)\w

[Subroutines::ProtectPrivateSubs]

[Subroutines::RequireArgUnpacking]
[-Subroutines::RequireArgUnpacking]

[Subroutines::RequireFinalReturn]
[-Subroutines::RequireFinalReturn]

[TestingAndDebugging::ProhibitNoStrict]

Expand Down Expand Up @@ -374,7 +374,7 @@ base_max = 130

[ValuesAndExpressions::ProhibitComplexVersion]

[ValuesAndExpressions::ProhibitConstantPragma]
[-ValuesAndExpressions::ProhibitConstantPragma]

[ValuesAndExpressions::ProhibitDuplicateHashKeys]

Expand Down
67 changes: 67 additions & 0 deletions t/01-Provider/05-filenames.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@

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,
),
);
}

__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 { /missing file <C:\\/ } @{ $builder->log_messages } ), "Bogus file at C:\\ warned" );
ok( !( grep { /missing file <lib\/Example/ } @{ $builder->log_messages } ), "Example.pm is not in error" );

note explain $builder->log_messages;
done_testing;
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;