From abbd9248e529159d05149535ce347a747979c66d Mon Sep 17 00:00:00 2001 From: Kent Fredric Date: Mon, 18 Jul 2011 14:30:41 +1200 Subject: [PATCH 1/9] fix auto_prereqs_skip for arrays --- Changes | 5 +++++ lib/Dist/Zilla/PluginBundle/Author/KENTNL.pm | 13 ++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Changes b/Changes index e29b2b32..e4da2771 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,11 @@ Revision history for {{$dist->name}} {{$NEXT}} + [Bugs] + - Reworked handling of auto_prereqs_skip not to carp needlessly. + + [Features] + - Can use multiple values of auto_prereqs_skip now. 1.0.13 2011-07-17T01:06:15Z [Bugs] diff --git a/lib/Dist/Zilla/PluginBundle/Author/KENTNL.pm b/lib/Dist/Zilla/PluginBundle/Author/KENTNL.pm index 0b1b51c0..7ebc3aef 100644 --- a/lib/Dist/Zilla/PluginBundle/Author/KENTNL.pm +++ b/lib/Dist/Zilla/PluginBundle/Author/KENTNL.pm @@ -186,6 +186,8 @@ sub _if_git_versions { return @{$else}; } +sub mvp_multivalue_args { return qw( auto_prereq_skip ) } + sub bundle_config { my ( $self, $section ) = @_; my $class = ( ref $self ) || $self; @@ -196,6 +198,15 @@ sub bundle_config { $twitter_conf->{hash_tags} .= q{ } . $extra_hash if $extra_hash; my $warn_no_git = _if_git_versions( $arg, [1], [0] ); + if ( not defined $arg->{auto_prereqs_skip} ) { + $arg->{auto_prereqs_skip} = []; + } + + if ( not ref $arg->{auto_prereqs_skip} eq 'ARRAY' ) { + require Carp; + Carp::carp('[Author::KENTNL] auto_prereqs_skip is expected to be an array ref'); + } + my @config = map { _expand( $class, $_->[0], $_->[1] ) } ( [ _if_git_versions( @@ -228,7 +239,7 @@ sub bundle_config { [ 'ReadmeFromPod' => {} ], [ 'ManifestSkip' => {} ], [ 'Manifest' => {} ], - [ 'AutoPrereqs' => { skip => [ _defined_or( $arg , auto_prereqs_skip => qw{}, 1 )] } ], + [ 'AutoPrereqs' => { skip => $arg->{auto_prereqs_skip} } ], [ 'Prereqs' => { -name => 'BundleDevelNeeds', From 7e672173f82681d4d9188ec22f79f4cf82b156ba Mon Sep 17 00:00:00 2001 From: Kent Fredric Date: Tue, 19 Jul 2011 06:44:26 +1200 Subject: [PATCH 2/9] flag checking --- lib/Dist/Zilla/PluginBundle/Author/KENTNL.pm | 39 ++++++++++++++++++-- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/lib/Dist/Zilla/PluginBundle/Author/KENTNL.pm b/lib/Dist/Zilla/PluginBundle/Author/KENTNL.pm index 7ebc3aef..9c781749 100644 --- a/lib/Dist/Zilla/PluginBundle/Author/KENTNL.pm +++ b/lib/Dist/Zilla/PluginBundle/Author/KENTNL.pm @@ -140,7 +140,7 @@ sub _mk_only { return () if exists $ENV{ 'KENTNL_NO' . $envname }; return @rest unless defined $args; return @rest unless ref $args eq 'HASH'; - return @rest unless exists $args->{ 'no' . $argfield }; + return @rest unless exists $args->{ 'no_' . $argfield }; return (); }; { @@ -186,18 +186,49 @@ sub _if_git_versions { return @{$else}; } -sub mvp_multivalue_args { return qw( auto_prereq_skip ) } +sub _params_list { + return ( + qw( :version auto_prereqs_skip git_versions twitter_only release_fail no_cpan no_git no_twitter twitter_hash_tags twitter_extra_hash_tags ), + ( map { 'version_' . $_ } qw( major minor ), ( map { 'rel_' . $_ } qw( year month day hour time_zone ) ) ), + qw( relea0se_fail ) + ); +} + +sub _param_checker { + my $_self = shift; + + my %params_hash = map { $_ => 1 } $_self->_params_list; + + return sub { + + my ( $self, $param ) = @_; + if ( not exists $params_hash{$param} ) { + require Carp; + Carp::croak("[Author::KENTNL] Parameter $param doesn't appear to be supported"); + } + + }; +} + +sub mvp_multivalue_args { return qw( auto_prereqs_skip ) } sub bundle_config { my ( $self, $section ) = @_; my $class = ( ref $self ) || $self; - my $arg = $section->{payload}; + my $arg = $section->{payload}; + my $twitter_conf = { hash_tags => _defined_or( $arg, twitter_hash_tags => '#perl #cpan' ) }; - my $extra_hash = _defined_or( $arg, twitter_extra_hash_tags => q{}, 1 ); + my $extra_hash = _defined_or( $arg, twitter_extra_hash_tags => q{}, 1 ); $twitter_conf->{hash_tags} .= q{ } . $extra_hash if $extra_hash; my $warn_no_git = _if_git_versions( $arg, [1], [0] ); + my $checker = $self->_param_checker; + + for my $param ( keys %{$arg} ) { + $checker->( $self, $param ); + } + if ( not defined $arg->{auto_prereqs_skip} ) { $arg->{auto_prereqs_skip} = []; } From ddafd6389e8085c1821e6916ad72081804dbe194 Mon Sep 17 00:00:00 2001 From: Kent Fredric Date: Tue, 19 Jul 2011 06:45:28 +1200 Subject: [PATCH 3/9] Update changelog --- Changes | 1 + 1 file changed, 1 insertion(+) diff --git a/Changes b/Changes index e4da2771..10a5ebe1 100644 --- a/Changes +++ b/Changes @@ -6,6 +6,7 @@ Revision history for {{$dist->name}} [Features] - Can use multiple values of auto_prereqs_skip now. + - Now stricter about flags passed to detect typos. 1.0.13 2011-07-17T01:06:15Z [Bugs] From 9879b59273b8c07777f79ca13cd8c74d35af3db4 Mon Sep 17 00:00:00 2001 From: Kent Fredric Date: Tue, 19 Jul 2011 06:46:09 +1200 Subject: [PATCH 4/9] inject example auto_prereqs_skip into minted dist.ini --- lib/Dist/Zilla/Plugin/Author/KENTNL/DistINI.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Dist/Zilla/Plugin/Author/KENTNL/DistINI.pm b/lib/Dist/Zilla/Plugin/Author/KENTNL/DistINI.pm index 1c363ba8..2846d3ce 100644 --- a/lib/Dist/Zilla/Plugin/Author/KENTNL/DistINI.pm +++ b/lib/Dist/Zilla/Plugin/Author/KENTNL/DistINI.pm @@ -105,6 +105,7 @@ sub gather_files { '; version_rel_hour = %{rel_hour}n', # '; version_rel_time_zone = %{tz}s', # 'twitter_hash_tags = %{tags}s', # + '; auto_prereqs_skip = File::Find', # $empty, # '[Prereqs]', # $empty, # From a8b0e40c0e293eb8b2fd1e2e59821dcbef6dc2bb Mon Sep 17 00:00:00 2001 From: Kent Fredric Date: Tue, 19 Jul 2011 06:46:54 +1200 Subject: [PATCH 5/9] Update changelog --- Changes | 1 + 1 file changed, 1 insertion(+) diff --git a/Changes b/Changes index 10a5ebe1..a1246162 100644 --- a/Changes +++ b/Changes @@ -7,6 +7,7 @@ Revision history for {{$dist->name}} [Features] - Can use multiple values of auto_prereqs_skip now. - Now stricter about flags passed to detect typos. + - Minted dists now have an example auto_prereqs_skip 1.0.13 2011-07-17T01:06:15Z [Bugs] From 91d71a3de04e2e63d49f973ecb36c7b350a31466 Mon Sep 17 00:00:00 2001 From: Kent Fredric Date: Tue, 19 Jul 2011 09:17:30 +1200 Subject: [PATCH 6/9] minter test now does auto-prereq checking and tests skip flags --- t/01-Minter.t | 101 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 94 insertions(+), 7 deletions(-) diff --git a/t/01-Minter.t b/t/01-Minter.t index fd146290..f15bf358 100644 --- a/t/01-Minter.t +++ b/t/01-Minter.t @@ -6,6 +6,7 @@ use Test::More; use FindBin; use Path::Class qw( dir ); use Test::Output qw(); +use JSON qw( from_json ); my ( $root, $corpus, $global ); @@ -15,7 +16,7 @@ BEGIN { $global = $corpus->subdir('global'); } -$ENV{'GIT_AUTHOR_NAME'} = $ENV{'GIT_COMMITTER_NAME'} = 'Anon Y. Mus'; +$ENV{'GIT_AUTHOR_NAME'} = $ENV{'GIT_COMMITTER_NAME'} = 'Anon Y. Mus'; $ENV{'GIT_AUTHOR_EMAIL'} = $ENV{'GIT_COMMITTER_EMAIL'} = 'anonymus@example.org'; use Test::File::ShareDir 0.3.0 -share => @@ -24,10 +25,10 @@ use Test::DZil; my $tzil; - subtest 'mint files' => sub { - $tzil = Minter->_new_from_profile( [ 'Author::KENTNL' => 'default' ], { name => 'DZT-Minty', }, { global_config_root => $global }, ); + $tzil = + Minter->_new_from_profile( [ 'Author::KENTNL' => 'default' ], { name => 'DZT-Minty', }, { global_config_root => $global }, ); pass('Loaded minter config'); @@ -84,6 +85,56 @@ subtest 'build minting' => sub { pass("Got minted dir"); + subtest 'Mangle minted dist.ini for experimental purposes' => sub { + + my $old = $tmpdir->file('dist.ini'); + my $new = $tmpdir->file('dist.ini.new'); + my $distini = $old->openr(); + my $newdistini = $new->openw(); + + while ( defined( my $line = <$distini> ) ) { + print $newdistini $line; + if ( $line =~ /auto_prereqs_skip/ ) { + note "Found skip line: ", explain( { line => $line } ); + pass "Found skip line: $."; + print $newdistini "auto_prereqs_skip = Bogus\n"; + print $newdistini "auto_prereqs_skip = OtherBogus\n"; + } + } + + close $distini; + close $newdistini; + + $old->remove(); + + rename "$new", "$old" or fail("Can't rename $new to $old"); + + }; + + subtest 'Create fake pm with deps to be ignored' => sub { + + my $fn = $tmpdir->subdir('lib')->subdir('DZT')->file('Mintiniator.pm'); + my $fh = $fn->openw(); + + print $fh <<'EOF'; +use strict; +use warnings; +package DZT::Mintiniator; + +# ABSTRACT: Test package to test auto prerequisites skip behaviour + +if(0){ # Stop it actually failing + require Bogus; + require OtherBogus; + require SomethingReallyWanted; +} + +1; +EOF + + pass('Generated file'); + }; + my $bzil = Builder->from_config( { dist_root => $tmpdir }, {}, { global_config_root => $global }, ); pass("Loaded builder configuration"); @@ -111,17 +162,20 @@ subtest 'build minting' => sub { }; } ); - if ( defined $exception ) { - note explain $@; + note explain { 'output was' => { out => $stdout, err => $stderr } }; + + if ( defined $exception ) { + note explain $exception; + # system("urxvt -e bash"); # XXX DEVELOPMENT die $@; } - note explain { 'output was' => { out => $stdout, err => $stderr } }; # system("find",$bzil->tempdir ); my %expected_files = map { $_ => 1 } qw( lib/DZT/Minty.pm + lib/DZT/Mintiniator.pm weaver.ini perlcritic.rc Changes @@ -146,10 +200,12 @@ subtest 'build minting' => sub { ); my %got_files; + my %got_files_refs; for my $file ( @{ $bzil->files } ) { my $name = $file->name; $got_files{$name} = 0 if not exists $got_files{$name}; $got_files{$name} += 1; + $got_files_refs{$name} = $file; } note explain { got => \%got_files, expected => \%expected_files }; @@ -158,7 +214,38 @@ subtest 'build minting' => sub { is_deeply( \%got_files, \%expected_files, 'All expected mint files exist' ); + my $data = from_json( dir( $bzil->tempdir )->subdir('build')->file('META.json')->slurp() ); + + note explain $data; + + is_deeply( + $data->{prereqs}, + { + build => { requires => { 'Module::Build' => '0.3601' }, }, + configure => { requires => { 'Module::Build' => '0.3601' }, }, + develop => { + recommends => { 'Dist::Zilla::PluginBundle::Author::KENTNL::Lite' => '0.01009803' }, + requires => { 'Dist::Zilla::PluginBundle::Author::KENTNL::Lite' => 0 }, + suggests => { 'Dist::Zilla::PluginBundle::Author::KENTNL' => 'v1.0.0' }, + }, + runtime => { + requires => { + 'Moose' => 0, + 'SomethingReallyWanted' => 0, + }, + }, + test => { + requires => { + 'English' => 0, + 'File::Find' => 0, + 'File::Temp' => 0, + 'Test::More' => '0.88', + }, + } + }, + 'Autodetected pre-reqs are sane' + ); + }; done_testing; - From ac4a305240f19af914cde7ab5ca6715762a09afe Mon Sep 17 00:00:00 2001 From: Kent Fredric Date: Tue, 19 Jul 2011 09:20:06 +1200 Subject: [PATCH 7/9] update changelog --- Changes | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Changes b/Changes index a1246162..196dccee 100644 --- a/Changes +++ b/Changes @@ -9,6 +9,10 @@ Revision history for {{$dist->name}} - Now stricter about flags passed to detect typos. - Minted dists now have an example auto_prereqs_skip + [Tests] + - Minter test now tests auto_prereq generation and the auto_prereqs_skip + flag. + 1.0.13 2011-07-17T01:06:15Z [Bugs] - Fixed an issue where the change of Dzil's Autoprereqs 'skip' parameter From f666c18e251183952730f712a01d81d31c218299 Mon Sep 17 00:00:00 2001 From: Kent Fredric Date: Tue, 19 Jul 2011 09:23:45 +1200 Subject: [PATCH 8/9] pod coverage hacjk --- lib/Dist/Zilla/PluginBundle/Author/KENTNL.pm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/Dist/Zilla/PluginBundle/Author/KENTNL.pm b/lib/Dist/Zilla/PluginBundle/Author/KENTNL.pm index 9c781749..59c48cdc 100644 --- a/lib/Dist/Zilla/PluginBundle/Author/KENTNL.pm +++ b/lib/Dist/Zilla/PluginBundle/Author/KENTNL.pm @@ -210,6 +210,14 @@ sub _param_checker { }; } +=begin Pod::Coverage + + mvp_multivalue_args + +=end Pod::Coverage + +=cut + sub mvp_multivalue_args { return qw( auto_prereqs_skip ) } sub bundle_config { From c3d3725e590f5336c8baf680bd13e01fe1106bff Mon Sep 17 00:00:00 2001 From: Kent Fredric Date: Tue, 19 Jul 2011 09:24:38 +1200 Subject: [PATCH 9/9] v1.0.14 [Bugs] - Reworked handling of auto_prereqs_skip not to carp needlessly. [Features] - Can use multiple values of auto_prereqs_skip now. - Now stricter about flags passed to detect typos. - Minted dists now have an example auto_prereqs_skip [Tests] - Minter test now tests auto_prereq generation and the auto_prereqs_skip flag. --- Changes | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Changes b/Changes index 196dccee..fb2b6513 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,8 @@ Revision history for {{$dist->name}} {{$NEXT}} + +1.0.14 2011-07-18T21:23:49Z [Bugs] - Reworked handling of auto_prereqs_skip not to carp needlessly.