diff --git a/Build.PL b/Build.PL index ef34bf4..a42643b 100644 --- a/Build.PL +++ b/Build.PL @@ -17,7 +17,7 @@ my %module_build_args = ( "Kent Fredric " ], "dist_name" => "Dist-Zilla-Plugin-Bootstrap-lib", - "dist_version" => "0.03000101", + "dist_version" => "0.03000200", "license" => "perl", "module_name" => "Dist::Zilla::Plugin::Bootstrap::lib", "recommends" => {}, @@ -34,8 +34,11 @@ my %module_build_args = ( }, "script_files" => [], "test_requires" => { + "Dist::Zilla" => 0, + "File::Copy::Recursive" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, + "Path::FindDev" => 0, "Test::More" => "0.98" } ); diff --git a/Changes b/Changes index c84e1f8..d91e964 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,15 @@ Revision history for Dist-Zilla-Plugin-Bootstrap-lib +0.03000200 2013-09-03T03:36:10Z + [!Minor] + - Add tests + - Minor refactor + + [Dependencies::Added / test requires] + - Dist::Zilla + - File::Copy::Recursive + - Path::FindDev + 0.03000101 2013-08-31T01:52:46Z [Bugfix] - accidental typo with boostrap_dir instead of bootstrap_dir diff --git a/MANIFEST b/MANIFEST index 010a756..fb72db9 100644 --- a/MANIFEST +++ b/MANIFEST @@ -7,11 +7,32 @@ MANIFEST META.json META.yml README +corpus/fake_dist_01/dist.ini +corpus/fake_dist_01/lib/E.pm +corpus/fake_dist_02/dist.ini +corpus/fake_dist_02/lib/E.pm +corpus/fake_dist_03/E-0.01/META.json +corpus/fake_dist_03/E-0.01/dist.ini +corpus/fake_dist_03/E-0.01/lib/E.pm +corpus/fake_dist_03/dist.ini +corpus/fake_dist_03/lib/E.pm +corpus/fake_dist_04/dist.ini +corpus/fake_dist_04/lib/E.pm +corpus/fake_dist_05/E-0.01/META.json +corpus/fake_dist_05/E-0.01/dist.ini +corpus/fake_dist_05/E-0.01/lib/E.pm +corpus/fake_dist_05/dist.ini +corpus/fake_dist_05/lib/E.pm dist.ini lib/Dist/Zilla/Plugin/Bootstrap/lib.pm perlcritic.rc t/00-compile.t t/000-report-versions-tiny.t +t/01-basic.t +t/02-try_built.t +t/03-try_built-pass2.t +t/04-try_built_nofallback.t +t/05-try_built_nofallback-pass2.t weaver.ini xt/author/critic.t xt/release/cpan-changes.t diff --git a/META.json b/META.json index f853f51..8711b89 100644 --- a/META.json +++ b/META.json @@ -56,8 +56,11 @@ }, "test" : { "requires" : { + "Dist::Zilla" : "0", + "File::Copy::Recursive" : "0", "IO::Handle" : "0", "IPC::Open3" : "0", + "Path::FindDev" : "0", "Test::More" : "0.98" } } @@ -65,7 +68,7 @@ "provides" : { "Dist::Zilla::Plugin::Bootstrap::lib" : { "file" : "lib/Dist/Zilla/Plugin/Bootstrap/lib.pm", - "version" : "0.03000101" + "version" : "0.03000200" } }, "release_status" : "stable", @@ -80,16 +83,19 @@ "web" : "https://github.com/kentfredric/Dist-Zilla-Plugin-Bootstrap-lib" } }, - "version" : "0.03000101", + "version" : "0.03000200", "x_BuiltWith" : { "modules" : { "Cwd" : "3.40", + "Dist::Zilla" : "4.300037", "Dist::Zilla::PluginBundle::Author::KENTNL" : "1.8.3", "Dist::Zilla::PluginBundle::Author::KENTNL::Lite" : "NA(possibly not installed)", + "File::Copy::Recursive" : "0.38", "IO::Handle" : "1.34", "IPC::Open3" : "1.13", "Module::Build" : "0.4007", "Moo::HandleMoose::FakeMetaClass" : "NA(undef)", + "Path::FindDev" : "0.2.0", "Path::Tiny" : "0.031", "Pod::Coverage::TrustPod" : "0.100002", "Role::Tiny" : "1.003001", @@ -135,7 +141,7 @@ } }, "name" : "Bootstrap::lib", - "version" : "0.03000101" + "version" : "0.03000200" }, { "class" : "Dist::Zilla::Plugin::Git::NextVersion", @@ -449,11 +455,11 @@ "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { - "phase" : "runtime", + "phase" : "test", "type" : "requires" } }, - "name" : "Prereqs", + "name" : "TestRequires", "version" : "4.300037" }, { diff --git a/META.yml b/META.yml index 6dcc7b3..26d504d 100644 --- a/META.yml +++ b/META.yml @@ -3,9 +3,12 @@ abstract: 'A minimal boot-strapping for Dist::Zilla Plug-ins.' author: - 'Kent Fredric ' build_requires: + Dist::Zilla: 0 + File::Copy::Recursive: 0 IO::Handle: 0 IPC::Open3: 0 Module::Build: 0.4007 + Path::FindDev: 0 Test::More: 0.98 configure_requires: Module::Build: 0.4007 @@ -19,7 +22,7 @@ name: Dist-Zilla-Plugin-Bootstrap-lib provides: Dist::Zilla::Plugin::Bootstrap::lib: file: lib/Dist/Zilla/Plugin/Bootstrap/lib.pm - version: 0.03000101 + version: 0.03000200 requires: Cwd: 0 Moo::HandleMoose::FakeMetaClass: 0 @@ -33,16 +36,19 @@ resources: bugtracker: https://github.com/kentfredric/Dist-Zilla-Plugin-Bootstrap-lib/issues homepage: https://github.com/kentfredric/Dist-Zilla-Plugin-Bootstrap-lib repository: https://github.com/kentfredric/Dist-Zilla-Plugin-Bootstrap-lib.git -version: 0.03000101 +version: 0.03000200 x_BuiltWith: modules: Cwd: 3.40 + Dist::Zilla: 4.300037 Dist::Zilla::PluginBundle::Author::KENTNL: 1.8.3 Dist::Zilla::PluginBundle::Author::KENTNL::Lite: 'NA(possibly not installed)' + File::Copy::Recursive: 0.38 IO::Handle: 1.34 IPC::Open3: 1.13 Module::Build: 0.4007 Moo::HandleMoose::FakeMetaClass: NA(undef) + Path::FindDev: 0.2.0 Path::Tiny: 0.031 Pod::Coverage::TrustPod: 0.100002 Role::Tiny: 1.003001 @@ -80,7 +86,7 @@ x_Dist_Zilla: Dist::Zilla::Plugin::Bootstrap::lib: try_built: ~ name: Bootstrap::lib - version: 0.03000101 + version: 0.03000200 - class: Dist::Zilla::Plugin::Git::NextVersion name: '@Author::KENTNL/Git::NextVersion' @@ -328,9 +334,9 @@ x_Dist_Zilla: class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: - phase: runtime + phase: test type: requires - name: Prereqs + name: TestRequires version: 4.300037 - class: Dist::Zilla::Plugin::FinderCode diff --git a/README b/README index 75d7a30..9e8d6c0 100644 --- a/README +++ b/README @@ -3,7 +3,7 @@ NAME Dist::Zilla Plug-ins. VERSION - version 0.03000101 + version 0.03000200 SYNOPSIS [Bootstrap::lib] diff --git a/corpus/fake_dist_01/dist.ini b/corpus/fake_dist_01/dist.ini new file mode 100644 index 0000000..070e7de --- /dev/null +++ b/corpus/fake_dist_01/dist.ini @@ -0,0 +1,12 @@ +name = E +version = 0.01 +author = Kent Fredric +license = Perl_5 +copyright_holder = Kent Fredric + +[Bootstrap::lib] +[MetaConfig] +[MetaJSON] +[GatherDir] +[=E] +[PruneCruft] diff --git a/corpus/fake_dist_01/lib/E.pm b/corpus/fake_dist_01/lib/E.pm new file mode 100644 index 0000000..f91b2b0 --- /dev/null +++ b/corpus/fake_dist_01/lib/E.pm @@ -0,0 +1,13 @@ + +use strict; +use warnings; + +package E; + +# ABSTRACT: Fake dist stub + +use Moose; +with 'Dist::Zilla::Role::Plugin'; + +1; + diff --git a/corpus/fake_dist_02/dist.ini b/corpus/fake_dist_02/dist.ini new file mode 100644 index 0000000..7f8d3d3 --- /dev/null +++ b/corpus/fake_dist_02/dist.ini @@ -0,0 +1,14 @@ +name = E +version = 0.01 +author = Kent Fredric +license = Perl_5 +copyright_holder = Kent Fredric + +[Bootstrap::lib] +try_built = 1 + +[MetaConfig] +[MetaJSON] +[GatherDir] +[=E] +[PruneCruft] diff --git a/corpus/fake_dist_02/lib/E.pm b/corpus/fake_dist_02/lib/E.pm new file mode 100644 index 0000000..f91b2b0 --- /dev/null +++ b/corpus/fake_dist_02/lib/E.pm @@ -0,0 +1,13 @@ + +use strict; +use warnings; + +package E; + +# ABSTRACT: Fake dist stub + +use Moose; +with 'Dist::Zilla::Role::Plugin'; + +1; + diff --git a/corpus/fake_dist_03/E-0.01/META.json b/corpus/fake_dist_03/E-0.01/META.json new file mode 100644 index 0000000..f8358c9 --- /dev/null +++ b/corpus/fake_dist_03/E-0.01/META.json @@ -0,0 +1,100 @@ +{ + "abstract" : "Fake dist stub", + "author" : [ + "Kent Fredric" + ], + "dynamic_config" : 0, + "generated_by" : "Dist::Zilla version 4.300037, CPAN::Meta::Converter version 2.132140", + "license" : [ + "perl_5" + ], + "meta-spec" : { + "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", + "version" : "2" + }, + "name" : "E", + "prereqs" : {}, + "release_status" : "stable", + "version" : "0.01", + "x_Dist_Zilla" : { + "perl" : { + "version" : "5.018000" + }, + "plugins" : [ + { + "class" : "Dist::Zilla::Plugin::Bootstrap::lib", + "config" : { + "Dist::Zilla::Plugin::Bootstrap::lib" : { + "fallback" : 1, + "try_built" : "1" + } + }, + "name" : "Bootstrap::lib", + "version" : "0.03000101" + }, + { + "class" : "Dist::Zilla::Plugin::MetaConfig", + "name" : "MetaConfig", + "version" : "4.300037" + }, + { + "class" : "Dist::Zilla::Plugin::MetaJSON", + "name" : "MetaJSON", + "version" : "4.300037" + }, + { + "class" : "Dist::Zilla::Plugin::GatherDir", + "name" : "GatherDir", + "version" : "4.300037" + }, + { + "class" : "E", + "name" : "=E", + "version" : null + }, + { + "class" : "Dist::Zilla::Plugin::PruneCruft", + "name" : "PruneCruft", + "version" : "4.300037" + }, + { + "class" : "Dist::Zilla::Plugin::FinderCode", + "name" : ":InstallModules", + "version" : "4.300037" + }, + { + "class" : "Dist::Zilla::Plugin::FinderCode", + "name" : ":IncModules", + "version" : "4.300037" + }, + { + "class" : "Dist::Zilla::Plugin::FinderCode", + "name" : ":TestFiles", + "version" : "4.300037" + }, + { + "class" : "Dist::Zilla::Plugin::FinderCode", + "name" : ":ExecFiles", + "version" : "4.300037" + }, + { + "class" : "Dist::Zilla::Plugin::FinderCode", + "name" : ":ShareFiles", + "version" : "4.300037" + }, + { + "class" : "Dist::Zilla::Plugin::FinderCode", + "name" : ":MainModule", + "version" : "4.300037" + } + ], + "zilla" : { + "class" : "Dist::Zilla::Dist::Builder", + "config" : { + "is_trial" : "0" + }, + "version" : "4.300037" + } + } +} + diff --git a/corpus/fake_dist_03/E-0.01/dist.ini b/corpus/fake_dist_03/E-0.01/dist.ini new file mode 100644 index 0000000..7f8d3d3 --- /dev/null +++ b/corpus/fake_dist_03/E-0.01/dist.ini @@ -0,0 +1,14 @@ +name = E +version = 0.01 +author = Kent Fredric +license = Perl_5 +copyright_holder = Kent Fredric + +[Bootstrap::lib] +try_built = 1 + +[MetaConfig] +[MetaJSON] +[GatherDir] +[=E] +[PruneCruft] diff --git a/corpus/fake_dist_03/E-0.01/lib/E.pm b/corpus/fake_dist_03/E-0.01/lib/E.pm new file mode 100644 index 0000000..f91b2b0 --- /dev/null +++ b/corpus/fake_dist_03/E-0.01/lib/E.pm @@ -0,0 +1,13 @@ + +use strict; +use warnings; + +package E; + +# ABSTRACT: Fake dist stub + +use Moose; +with 'Dist::Zilla::Role::Plugin'; + +1; + diff --git a/corpus/fake_dist_03/dist.ini b/corpus/fake_dist_03/dist.ini new file mode 100644 index 0000000..7f8d3d3 --- /dev/null +++ b/corpus/fake_dist_03/dist.ini @@ -0,0 +1,14 @@ +name = E +version = 0.01 +author = Kent Fredric +license = Perl_5 +copyright_holder = Kent Fredric + +[Bootstrap::lib] +try_built = 1 + +[MetaConfig] +[MetaJSON] +[GatherDir] +[=E] +[PruneCruft] diff --git a/corpus/fake_dist_03/lib/E.pm b/corpus/fake_dist_03/lib/E.pm new file mode 100644 index 0000000..f91b2b0 --- /dev/null +++ b/corpus/fake_dist_03/lib/E.pm @@ -0,0 +1,13 @@ + +use strict; +use warnings; + +package E; + +# ABSTRACT: Fake dist stub + +use Moose; +with 'Dist::Zilla::Role::Plugin'; + +1; + diff --git a/corpus/fake_dist_04/dist.ini b/corpus/fake_dist_04/dist.ini new file mode 100644 index 0000000..747d7fe --- /dev/null +++ b/corpus/fake_dist_04/dist.ini @@ -0,0 +1,15 @@ +name = E +version = 0.01 +author = Kent Fredric +license = Perl_5 +copyright_holder = Kent Fredric + +[Bootstrap::lib] +try_built = 1 +no_fallback = 1 + +[MetaConfig] +[MetaJSON] +[GatherDir] +[=E] +[PruneCruft] diff --git a/corpus/fake_dist_04/lib/E.pm b/corpus/fake_dist_04/lib/E.pm new file mode 100644 index 0000000..f91b2b0 --- /dev/null +++ b/corpus/fake_dist_04/lib/E.pm @@ -0,0 +1,13 @@ + +use strict; +use warnings; + +package E; + +# ABSTRACT: Fake dist stub + +use Moose; +with 'Dist::Zilla::Role::Plugin'; + +1; + diff --git a/corpus/fake_dist_05/E-0.01/META.json b/corpus/fake_dist_05/E-0.01/META.json new file mode 100644 index 0000000..c28ce45 --- /dev/null +++ b/corpus/fake_dist_05/E-0.01/META.json @@ -0,0 +1,96 @@ +{ + "abstract" : "Fake dist stub", + "author" : [ + "Kent Fredric" + ], + "dynamic_config" : 0, + "generated_by" : "Dist::Zilla version 4.300037, CPAN::Meta::Converter version 2.132140", + "license" : [ + "perl_5" + ], + "meta-spec" : { + "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", + "version" : "2" + }, + "name" : "E", + "prereqs" : {}, + "release_status" : "stable", + "version" : "0.01", + "x_Dist_Zilla" : { + "perl" : { + "version" : "5.018000" + }, + "plugins" : [ + { + "class" : "Dist::Zilla::Plugin::Bootstrap::lib", + "config" : { + "Dist::Zilla::Plugin::Bootstrap::lib" : { + "fallback" : null, + "no_fallback" : "1", + "try_built" : "1" + } + }, + "name" : "Bootstrap::lib", + "version" : "0.03000101" + }, + { + "class" : "Dist::Zilla::Plugin::MetaConfig", + "name" : "MetaConfig", + "version" : "4.300037" + }, + { + "class" : "Dist::Zilla::Plugin::MetaJSON", + "name" : "MetaJSON", + "version" : "4.300037" + }, + { + "class" : "Dist::Zilla::Plugin::GatherDir", + "name" : "GatherDir", + "version" : "4.300037" + }, + { + "class" : "E", + "name" : "=E", + "version" : null + }, + { + "class" : "Dist::Zilla::Plugin::FinderCode", + "name" : ":InstallModules", + "version" : "4.300037" + }, + { + "class" : "Dist::Zilla::Plugin::FinderCode", + "name" : ":IncModules", + "version" : "4.300037" + }, + { + "class" : "Dist::Zilla::Plugin::FinderCode", + "name" : ":TestFiles", + "version" : "4.300037" + }, + { + "class" : "Dist::Zilla::Plugin::FinderCode", + "name" : ":ExecFiles", + "version" : "4.300037" + }, + { + "class" : "Dist::Zilla::Plugin::FinderCode", + "name" : ":ShareFiles", + "version" : "4.300037" + }, + { + "class" : "Dist::Zilla::Plugin::FinderCode", + "name" : ":MainModule", + "version" : "4.300037" + } + ], + "zilla" : { + "class" : "Dist::Zilla::Dist::Builder", + "config" : { + "is_trial" : "0" + }, + "version" : "4.300037" + } + } +} + diff --git a/corpus/fake_dist_05/E-0.01/dist.ini b/corpus/fake_dist_05/E-0.01/dist.ini new file mode 100644 index 0000000..121d431 --- /dev/null +++ b/corpus/fake_dist_05/E-0.01/dist.ini @@ -0,0 +1,14 @@ +name = E +version = 0.01 +author = Kent Fredric +license = Perl_5 +copyright_holder = Kent Fredric + +[Bootstrap::lib] +try_built = 1 +no_fallback = 1 + +[MetaConfig] +[MetaJSON] +[GatherDir] +[=E] diff --git a/corpus/fake_dist_05/E-0.01/lib/E.pm b/corpus/fake_dist_05/E-0.01/lib/E.pm new file mode 100644 index 0000000..f91b2b0 --- /dev/null +++ b/corpus/fake_dist_05/E-0.01/lib/E.pm @@ -0,0 +1,13 @@ + +use strict; +use warnings; + +package E; + +# ABSTRACT: Fake dist stub + +use Moose; +with 'Dist::Zilla::Role::Plugin'; + +1; + diff --git a/corpus/fake_dist_05/dist.ini b/corpus/fake_dist_05/dist.ini new file mode 100644 index 0000000..747d7fe --- /dev/null +++ b/corpus/fake_dist_05/dist.ini @@ -0,0 +1,15 @@ +name = E +version = 0.01 +author = Kent Fredric +license = Perl_5 +copyright_holder = Kent Fredric + +[Bootstrap::lib] +try_built = 1 +no_fallback = 1 + +[MetaConfig] +[MetaJSON] +[GatherDir] +[=E] +[PruneCruft] diff --git a/corpus/fake_dist_05/lib/E.pm b/corpus/fake_dist_05/lib/E.pm new file mode 100644 index 0000000..f91b2b0 --- /dev/null +++ b/corpus/fake_dist_05/lib/E.pm @@ -0,0 +1,13 @@ + +use strict; +use warnings; + +package E; + +# ABSTRACT: Fake dist stub + +use Moose; +with 'Dist::Zilla::Role::Plugin'; + +1; + diff --git a/dist.ini b/dist.ini index 349082f..b93005a 100644 --- a/dist.ini +++ b/dist.ini @@ -20,4 +20,5 @@ twitter_hash_tags = #perl #cpan ;version_rel_time_zone = Pacific/Auckland -[Prereqs] +[Prereqs / TestRequires ] +Dist::Zilla = 0 diff --git a/lib/Dist/Zilla/Plugin/Bootstrap/lib.pm b/lib/Dist/Zilla/Plugin/Bootstrap/lib.pm index ae76252..8bd88b2 100644 --- a/lib/Dist/Zilla/Plugin/Bootstrap/lib.pm +++ b/lib/Dist/Zilla/Plugin/Bootstrap/lib.pm @@ -6,7 +6,7 @@ BEGIN { $Dist::Zilla::Plugin::Bootstrap::lib::AUTHORITY = 'cpan:KENTNL'; } { - $Dist::Zilla::Plugin::Bootstrap::lib::VERSION = '0.03000101'; + $Dist::Zilla::Plugin::Bootstrap::lib::VERSION = '0.03000200'; } ## use critic; @@ -25,9 +25,7 @@ sub plugin_name { return 'Bootstrap::lib' } ## no critic (RequireArgUnpacking) -sub new { - return bless $_[1], $_[0]; -} +sub new { return bless $_[1], $_[0] } sub does { @@ -48,24 +46,6 @@ sub meta { sub dump_config { return { q{} . __PACKAGE__, $_[0]->{config} } } -sub _bootstrap_dir { - my ($dir) = @_; - require lib; - lib->import($dir); - return $dir; -} - -sub _bootstrap_source_lib { - my ($config) = @_; - - my $cwd = $config->{cwd}; - my $logger = $config->{logger}; - - my $libdir = $cwd->child('lib')->stringify; - $logger->log( [ 'bootstrapping %s', $libdir ] ); - return _bootstrap_dir($libdir); -} - sub _try_bootstrap_built { my ($config) = @_; @@ -74,26 +54,24 @@ sub _try_bootstrap_built { my $cwd = $config->{cwd}; my $fallback = $config->{fallback}; - my $libdir = $cwd->child($distname)->stringify; + my $libdir = $cwd->child($distname); $logger->log_debug( [ 'trying to bootstrap %s-*', $libdir ] ); my (@candidates) = grep { $_->basename =~ /^\Q$distname\E-/ } grep { $_->is_dir } $cwd->children; - if ( scalar @candidates != 1 and not $fallback ) { + if ( scalar @candidates == 1 ) { + return $candidates[0]->child('lib'); + } + $logger->log_debug( [ 'candidate: %s', $_->basename ] ) for @candidates; + + if ( not $fallback ) { $logger->log( [ 'candidates for bootstrap (%s) != 1, and fallback disabled. not bootstrapping', 0 + @candidates ] ); - $logger->log_debug( [ 'candidate: %s', $_->basename ] ) for @candidates; return; } - if ( scalar @candidates != 1 and $fallback ) { - $logger->log( [ 'candidates for bootstrap (%s) != 1, and fallback to boostrapping lib/', 0 + @candidates ] ); - $logger->log_debug( [ 'candidate: %s', $_->basename ] ) for @candidates; - return _bootstrap_dir( $cwd->child('lib')->stringify ); - } - my $found = $candidates[0]->child('lib'); - $logger->log( [ 'bootstrapping %s', $found->stringify ] ); - return _bootstrap_dir( $found->stringify ); + $logger->log( [ 'candidates for bootstrap (%s) != 1, fallback to boostrapping lib/', 0 + @candidates ] ); + return $cwd->child('lib'); } @@ -121,33 +99,36 @@ sub register_component { my $bootstrap_path; if ( not $payload->{try_built} ) { - $bootstrap_path = _bootstrap_source_lib( { cwd => $cwd, logger => $logger } ); + $bootstrap_path = $cwd->child('lib'); } else { - $bootstrap_path = - _try_bootstrap_built( { cwd => $cwd, logger => $logger, fallback => $payload->{fallback}, distname => $distname } ); + my $config = { cwd => $cwd, logger => $logger, fallback => $payload->{fallback}, distname => $distname }; + $bootstrap_path = _try_bootstrap_built($config); } - push @{ $zilla->plugins }, __PACKAGE__->new( - { - config => { - ( exists $payload->{try_built} ? ( try_built => $payload->{try_built} ) : () ), - ( exists $payload->{fallback} ? ( fallback => $payload->{fallback} ) : () ), - ( exists $payload->{no_fallback} ? ( no_fallback => $payload->{no_fallback} ) : () ), + if ( defined $bootstrap_path ) { + require lib; + lib->import("$bootstrap_path"); + $logger->log( [ 'Bootstrapping %s', "$bootstrap_path" ] ); + } - } + my $plugin_config = { + config => { + ( exists $payload->{try_built} ? ( try_built => $payload->{try_built} ) : () ), + ( exists $payload->{fallback} ? ( fallback => $payload->{fallback} ) : () ), + ( exists $payload->{no_fallback} ? ( no_fallback => $payload->{no_fallback} ) : () ), } - ); + }; - return unless defined $bootstrap_path; + push @{ $zilla->plugins }, $plugin_class->new($plugin_config); - my $root = Path::Tiny::path($bootstrap_path); + return unless defined $bootstrap_path; - my $it = $root->iterator( { recurse => 1 } ); + my $it = $bootstrap_path->iterator( { recurse => 1 } ); while ( my $file = $it->() ) { next unless $file->basename =~ /[.]pm$/msx; - my $rpath = $file->relative($root)->stringify; + my $rpath = $file->relative($bootstrap_path)->stringify; if ( exists $INC{$rpath} ) { $logger->log( [ '%s was not bootstrapped. You need to move Bootstrap::lib higher', $rpath ] ); } @@ -169,7 +150,7 @@ Dist::Zilla::Plugin::Bootstrap::lib - A minimal boot-strapping for Dist::Zilla P =head1 VERSION -version 0.03000101 +version 0.03000200 =head1 SYNOPSIS diff --git a/t/000-report-versions-tiny.t b/t/000-report-versions-tiny.t index 2b3b101..ec25bc4 100644 --- a/t/000-report-versions-tiny.t +++ b/t/000-report-versions-tiny.t @@ -49,12 +49,15 @@ sub pmver { } eval { $v .= pmver('Cwd','any version') }; +eval { $v .= pmver('Dist::Zilla','any version') }; eval { $v .= pmver('Dist::Zilla::PluginBundle::Author::KENTNL','v1.8.3') }; eval { $v .= pmver('Dist::Zilla::PluginBundle::Author::KENTNL::Lite','v1.3.0') }; +eval { $v .= pmver('File::Copy::Recursive','any version') }; eval { $v .= pmver('IO::Handle','any version') }; eval { $v .= pmver('IPC::Open3','any version') }; eval { $v .= pmver('Module::Build','0.4007') }; eval { $v .= pmver('Moo::HandleMoose::FakeMetaClass','any version') }; +eval { $v .= pmver('Path::FindDev','any version') }; eval { $v .= pmver('Path::Tiny','any version') }; eval { $v .= pmver('Pod::Coverage::TrustPod','any version') }; eval { $v .= pmver('Role::Tiny','any version') }; diff --git a/t/01-basic.t b/t/01-basic.t new file mode 100644 index 0000000..e0586eb --- /dev/null +++ b/t/01-basic.t @@ -0,0 +1,25 @@ +use strict; +use warnings; + +use Test::More; +use Path::FindDev qw( find_dev ); +use Path::Tiny; +use Cwd qw( cwd ); +use File::Copy::Recursive qw( rcopy ); + +my $source = find_dev('./')->child('corpus')->child('fake_dist_01'); +my $tempdir = Path::Tiny->tempdir; + +rcopy( "$source", "$tempdir" ); + +BAIL_OUT("test setup failed to copy to tempdir") if not -e -f $tempdir->child("dist.ini"); + +my $cwd = cwd(); +chdir "$tempdir"; + +is( system( "dzil", "build" ), 0, "dzil build ran ok" ); + +chdir $cwd; + +done_testing; + diff --git a/t/02-try_built.t b/t/02-try_built.t new file mode 100644 index 0000000..f59dae2 --- /dev/null +++ b/t/02-try_built.t @@ -0,0 +1,25 @@ +use strict; +use warnings; + +use Test::More; +use Path::FindDev qw( find_dev ); +use Path::Tiny; +use Cwd qw( cwd ); +use File::Copy::Recursive qw( rcopy ); + +my $source = find_dev('./')->child('corpus')->child('fake_dist_02'); +my $tempdir = Path::Tiny->tempdir; + +rcopy( "$source", "$tempdir" ); + +BAIL_OUT("test setup failed to copy to tempdir") if not -e -f $tempdir->child("dist.ini"); + +my $cwd = cwd(); +chdir "$tempdir"; + +is( system( "dzil", "build" ), 0, "dzil build ran ok" ); + +chdir $cwd; + +done_testing; + diff --git a/t/03-try_built-pass2.t b/t/03-try_built-pass2.t new file mode 100644 index 0000000..283aa60 --- /dev/null +++ b/t/03-try_built-pass2.t @@ -0,0 +1,25 @@ +use strict; +use warnings; + +use Test::More; +use Path::FindDev qw( find_dev ); +use Path::Tiny; +use Cwd qw( cwd ); +use File::Copy::Recursive qw( rcopy ); + +my $source = find_dev('./')->child('corpus')->child('fake_dist_03'); +my $tempdir = Path::Tiny->tempdir; + +rcopy( "$source", "$tempdir" ); + +BAIL_OUT("test setup failed to copy to tempdir") if not -e -f $tempdir->child("dist.ini"); + +my $cwd = cwd(); +chdir "$tempdir"; + +is( system( "dzil", "build" ), 0, "dzil build ran ok" ); + +chdir $cwd; + +done_testing; + diff --git a/t/04-try_built_nofallback.t b/t/04-try_built_nofallback.t new file mode 100644 index 0000000..41960c4 --- /dev/null +++ b/t/04-try_built_nofallback.t @@ -0,0 +1,26 @@ +use strict; +use warnings; + +use Test::More; +use Path::FindDev qw( find_dev ); +use Path::Tiny; +use Cwd qw( cwd ); +use File::Copy::Recursive qw( rcopy ); + +my $source = find_dev('./')->child('corpus')->child('fake_dist_04'); +my $tempdir = Path::Tiny->tempdir; + +rcopy( "$source", "$tempdir" ); + +BAIL_OUT("test setup failed to copy to tempdir") if not -e -f $tempdir->child("dist.ini"); + +my $cwd = cwd(); +chdir "$tempdir"; +diag "You can ignore the warning about dzil authordeps here"; + +isnt( system( "dzil", "build" ), 0, "dzil building a no-fallback dist that isnt installed fails" ); + +chdir $cwd; + +done_testing; + diff --git a/t/05-try_built_nofallback-pass2.t b/t/05-try_built_nofallback-pass2.t new file mode 100644 index 0000000..dcce193 --- /dev/null +++ b/t/05-try_built_nofallback-pass2.t @@ -0,0 +1,25 @@ +use strict; +use warnings; + +use Test::More; +use Path::FindDev qw( find_dev ); +use Path::Tiny; +use Cwd qw( cwd ); +use File::Copy::Recursive qw( rcopy ); + +my $source = find_dev('./')->child('corpus')->child('fake_dist_05'); +my $tempdir = Path::Tiny->tempdir; + +rcopy( "$source", "$tempdir" ); + +BAIL_OUT("test setup failed to copy to tempdir") if not -e -f $tempdir->child("dist.ini"); + +my $cwd = cwd(); +chdir "$tempdir"; + +is( system( "dzil", "build" ), 0, "dzil building a no-fallback dist a second time is ok" ); + +chdir $cwd; + +done_testing; +