diff options
author | 2013-03-25 20:06:16 +0000 | |
---|---|---|
committer | 2013-03-25 20:06:16 +0000 | |
commit | 898184e3e61f9129feb5978fad5a8c6865f00b92 (patch) | |
tree | 56f32aefc1eed60b534611007c7856f82697a205 /gnu/usr.bin/perl/cpan/Module-Build/t | |
parent | PGSHIFT -> PAGE_SHIFT (diff) | |
download | wireguard-openbsd-898184e3e61f9129feb5978fad5a8c6865f00b92.tar.xz wireguard-openbsd-898184e3e61f9129feb5978fad5a8c6865f00b92.zip |
import perl 5.16.3 from CPAN - worked on by Andrew Fresh and myself
Diffstat (limited to 'gnu/usr.bin/perl/cpan/Module-Build/t')
19 files changed, 694 insertions, 77 deletions
diff --git a/gnu/usr.bin/perl/cpan/Module-Build/t/actions/installdeps.t b/gnu/usr.bin/perl/cpan/Module-Build/t/actions/installdeps.t index 95e221d0add..5df98336b5c 100755 --- a/gnu/usr.bin/perl/cpan/Module-Build/t/actions/installdeps.t +++ b/gnu/usr.bin/perl/cpan/Module-Build/t/actions/installdeps.t @@ -3,7 +3,7 @@ use lib 't/lib'; use MBTest; use DistGen; -plan tests => 7; +plan tests => 6; # Ensure any Module::Build modules are loaded from correct directory blib_load('Module::Build'); @@ -33,8 +33,6 @@ my $out = stdout_of( sub { $dist->run_build('installdeps') }); ok( length($out), "ran mocked Build installdeps"); -my $expected = quotemeta(Module::Build->find_command($^X)); -like( $out, qr/$expected/i, "relative cpan_client resolved relative to \$^X" ); like( $out, qr/File::Spec/, "saw File::Spec prereq" ); like( $out, qr/Getopt::Long/, "saw Getopt::Long prereq" ); diff --git a/gnu/usr.bin/perl/cpan/Module-Build/t/actions/manifest_skip.t b/gnu/usr.bin/perl/cpan/Module-Build/t/actions/manifest_skip.t new file mode 100644 index 00000000000..a3677dd85c2 --- /dev/null +++ b/gnu/usr.bin/perl/cpan/Module-Build/t/actions/manifest_skip.t @@ -0,0 +1,54 @@ +use strict; +use lib 't/lib'; +use MBTest; +use DistGen; + +plan tests => 7; + +# Ensure any Module::Build modules are loaded from correct directory +blib_load('Module::Build'); + +# create dist object in a temp directory +# enter the directory and generate the skeleton files +my $dist = DistGen->new->chdir_in; +$dist->change_build_pl( + module_name => $dist->name, + requires => { + 'File::Spec' => 9999, + }, + build_requires => { + 'Getopt::Long' => 9998, + }, + cpan_client => $^X . ' -le print($_)for($^X,@ARGV)', +)->regen; + +ok( ! -e 'MANIFEST.SKIP', "MANIFEST.SKIP doesn't exist at start" ); + +# get a Module::Build object and test with it +my $mb; +stdout_stderr_of( sub { $mb = $dist->new_from_context('verbose' => 1) } ); +isa_ok( $mb, "Module::Build" ); + +my ($out, $err) = stdout_stderr_of( sub { + $dist->run_build('manifest_skip') +}); +ok( -e 'MANIFEST.SKIP', "'Build manifest_skip' creates MANIFEST.SKIP" ); +like( $out, qr/Creating a new MANIFEST.SKIP file/, "Saw creation message"); + +# shouldn't overwrite +my $old_mtime = -M 'MANIFEST.SKIP'; +($out, $err) = stdout_stderr_of( sub { + $dist->run_build('manifest_skip') +}); +like( $err, qr/MANIFEST.SKIP already exists/, + "Running it again warns about pre-existing MANIFEST.SKIP" +); +is( -M 'MANIFEST.SKIP', $old_mtime, "File does not appear modified" ); + +# cleanup +($out, $err) = stdout_stderr_of( sub { + $dist->run_build('distclean') +}); +ok( -e 'MANIFEST.SKIP', "MANIFEST.SKIP still exists after distclean" ); + +# vim:ts=2:sw=2:et:sta:sts=2 diff --git a/gnu/usr.bin/perl/cpan/Module-Build/t/basic.t b/gnu/usr.bin/perl/cpan/Module-Build/t/basic.t index 5d76ffaebd7..e26847e3d60 100755 --- a/gnu/usr.bin/perl/cpan/Module-Build/t/basic.t +++ b/gnu/usr.bin/perl/cpan/Module-Build/t/basic.t @@ -60,8 +60,8 @@ $dist->chdir_in; ok $flagged; ok $mb->prereq_failures; ok $mb->prereq_failures->{requires}{$dist->name}; - is $mb->prereq_failures->{requires}{$dist->name}{have}, 0.01; - is $mb->prereq_failures->{requires}{$dist->name}{need}, 3.14159265; + is $mb->prereq_failures->{requires}{$dist->name}{have}, "0.01"; + is $mb->prereq_failures->{requires}{$dist->name}{need}, "3.14159265"; $mb->dispatch('realclean'); $dist->clean; diff --git a/gnu/usr.bin/perl/cpan/Module-Build/t/bundled/Software/License.pm b/gnu/usr.bin/perl/cpan/Module-Build/t/bundled/Software/License.pm new file mode 100644 index 00000000000..6457ab60264 --- /dev/null +++ b/gnu/usr.bin/perl/cpan/Module-Build/t/bundled/Software/License.pm @@ -0,0 +1,56 @@ +# Modified from the original as a "mock" version for testing +use strict; +use warnings; +use 5.006; # warnings +package Software::License; +our $VERSION = 9999; + +sub new { + my ($class, $arg) = @_; + + # XXX changed from Carp::croak to die + die "no copyright holder specified" unless $arg->{holder}; + + bless $arg => $class; +} + + +sub year { defined $_[0]->{year} ? $_[0]->{year} : (localtime)[5]+1900 } +sub holder { $_[0]->{holder} } + +sub version { + my ($self) = @_; + my $pkg = ref $self ? ref $self : $self; + $pkg =~ s/.+:://; + my (undef, @vparts) = split /_/, $pkg; + + return unless @vparts; + return join '.', @vparts; +} + + +# sub meta1_name { return undef; } # sort this out later, should be easy +sub meta_name { return undef; } +sub meta_yml_name { $_[0]->meta_name } + +sub meta2_name { + my ($self) = @_; + my $meta1 = $self->meta_name; + + return undef unless defined $meta1; + + return $meta1 + if $meta1 =~ /\A(?:open_source|restricted|unrestricted|unknown)\z/; + + return undef; +} + +# XXX these are trivial mocks of the real thing +sub notice { 'NOTICE' } +sub license { 'LICENSE' } +sub fulltext { 'FULLTEXT' } + +1; + + + diff --git a/gnu/usr.bin/perl/cpan/Module-Build/t/compat.t b/gnu/usr.bin/perl/cpan/Module-Build/t/compat.t index 7e5a515eaaf..1546d2b814c 100755 --- a/gnu/usr.bin/perl/cpan/Module-Build/t/compat.t +++ b/gnu/usr.bin/perl/cpan/Module-Build/t/compat.t @@ -218,23 +218,25 @@ ok $mb, "Module::Build->new_from_context"; (my $libdir2 = $libdir) =~ s/libdir/lbiidr/; my $libarch2 = File::Spec->catdir($libdir2, 'arch'); + my $check_base = $libdir2; + $check_base =~ s/\]\z// if $^O eq 'VMS'; # trim trailing ] for appending other dirs SKIP: { my @cases = ( { label => "INSTALLDIRS=vendor", args => [ 'INSTALLDIRS=vendor', "INSTALLVENDORLIB=$libdir2", "INSTALLVENDORARCH=$libarch2"], - check => qr/\Q$libdir2\E .* Simple\.pm/ix, + check => qr/\Q$check_base\E .* Simple\.pm/ix, }, { label => "PREFIX=\$libdir2", args => [ "PREFIX=$libdir2"], - check => qr/\Q$libdir2\E .* Simple\.pm/ix, + check => qr/\Q$check_base\E .* Simple\.pm/ix, }, { label => "PREFIX=\$libdir2 LIB=mylib", args => [ "PREFIX=$libdir2", "LIB=mylib" ], - check => qr{\Q$libdir2\E[/\\]mylib[/\\]Simple\.pm}ix, + check => qr{\Q$check_base\E[/\\\.]mylib[/\\\]]Simple\.pm}ix, }, ); @@ -242,15 +244,8 @@ ok $mb, "Module::Build->new_from_context"; skip "Needs ExtUtils::Install 1.32 or later", 2 * @cases if ExtUtils::Install->VERSION < 1.32; - skip "Needs upstream patch at http://rt.cpan.org/Public/Bug/Display.html?id=55288", 2 * @cases - if $^O eq 'VMS'; - for my $c (@cases) { my @make_args = @{$c->{args}}; - if ($is_vms_mms) { # VMS MMK/MMS macros use different syntax. - $make_args[0] = '/macro=("' . join('","',@make_args) . '")'; - pop @make_args while scalar(@make_args) > 1; - } ($output) = stdout_stderr_of( sub { $result = $mb->run_perl_script('Makefile.PL', [], \@make_args); @@ -318,6 +313,63 @@ ok $mb, "Module::Build->new_from_context"; ok( ! exists $args->{TESTS}, 'Not using incorrect recursive tests key' ); } + 1 while unlink 'Makefile.PL'; + ok ! -e 'Makefile.PL', "Makefile.PL cleaned up"; +} + +{ + # make sure using prereq with '0.1.2' complains + $dist->change_build_pl({ + module_name => $distname, + license => 'perl', + requires => { + 'Foo::Frobnicate' => '0.1.2', + }, + create_makefile_pl => 'traditional', + }); + $dist->regen; + + my $mb; + stdout_stderr_of( sub { + $mb = Module::Build->new_from_context; + }); + + my $output = stdout_stderr_of( sub { $mb->do_create_makefile_pl } ); + ok -e 'Makefile.PL', "Makefile.PL created"; + like $output, qr/is not portable/, "Correctly complains and converts dotted-decimal"; + + my $file_contents = slurp 'Makefile.PL'; + like $file_contents, qr/Foo::Frobnicate.+0\.001002/, "Properly converted dotted-decimal"; + + 1 while unlink 'Makefile.PL'; + ok ! -e 'Makefile.PL', "Makefile.PL cleaned up"; +} + +{ + # make sure using invalid prereq blows up + $dist->change_build_pl({ + module_name => $distname, + license => 'perl', + requires => { + 'Foo::Frobnicate' => '3.5_2_7', + }, + create_makefile_pl => 'traditional', + }); + $dist->regen; + + ok ! -e 'Makefile.PL', "Makefile.PL doesn't exist before we start"; + + my $mb; + stdout_stderr_of( sub { + $mb = $dist->run_build_pl; + }); + + my ($output, $error) = stdout_stderr_of( sub { $dist->run_build('distmeta') } ); + like $error, qr/is not supported/ms, "Correctly dies when it encounters invalid prereq"; + ok ! -e 'Makefile.PL', "Makefile.PL NOT created"; + + 1 while unlink 'Makefile.PL'; + ok ! -e 'Makefile.PL', "Makefile.PL cleaned up"; } ######################################################### diff --git a/gnu/usr.bin/perl/cpan/Module-Build/t/lib/DistGen.pm b/gnu/usr.bin/perl/cpan/Module-Build/t/lib/DistGen.pm index 9fbd6d0c8ca..ae8ed343907 100644 --- a/gnu/usr.bin/perl/cpan/Module-Build/t/lib/DistGen.pm +++ b/gnu/usr.bin/perl/cpan/Module-Build/t/lib/DistGen.pm @@ -84,6 +84,8 @@ sub reset { my %options = @_; $options{name} ||= 'Simple'; + $options{version} ||= q{'0.01'}; + $options{license} ||= 'perl'; $options{dir} = File::Spec->rel2abs( defined $options{dir} ? $options{dir} : MBTest->tmpdir ); @@ -151,7 +153,7 @@ sub _gen_default_filedata { my \$builder = Module::Build->new( module_name => '$self->{name}', - license => 'perl', + license => '$self->{license}', ); \$builder->create_build_script(); @@ -164,7 +166,7 @@ sub _gen_default_filedata { my \$builder = Module::Build->new( module_name => '$self->{name}', - license => 'perl', + license => '$self->{license}', ); \$builder->create_build_script(); @@ -179,7 +181,7 @@ sub _gen_default_filedata { package $self->{name}; use vars qw( \$VERSION ); - \$VERSION = '0.01'; + \$VERSION = $self->{version}; use strict; @@ -214,7 +216,7 @@ sub _gen_default_filedata { $self->$add_unless($module_filename, undent(<<" ---")); package $self->{name}; - \$VERSION = '0.01'; + \$VERSION = $self->{version}; require Exporter; require DynaLoader; @@ -627,6 +629,8 @@ The C<new> method does not write any files -- see L</regen()> below. my $dist = DistGen->new( name => 'Foo::Bar', + version => '0.01', + license => 'perl', dir => MBTest->tmpdir, xs => 1, no_manifest => 0, @@ -642,6 +646,17 @@ The name of the module this distribution represents. The default is 'Simple'. This should be a "Foo::Bar" (module) name, not a "Foo-Bar" dist name. +=item version + +The version string that will be set. (E.g. C<our $VERSION = 0.01>) +Note -- to put this value in quotes, add those to the string. + + version => q{'0.01_01'} + +=item license + +The license string that will be set in Build.PL. Defaults to 'perl'. + =item dir The (parent) directory in which to create the distribution directory. The diff --git a/gnu/usr.bin/perl/cpan/Module-Build/t/lib/MBTest.pm b/gnu/usr.bin/perl/cpan/Module-Build/t/lib/MBTest.pm index 6dc4c8627a4..0df382fc6aa 100644 --- a/gnu/usr.bin/perl/cpan/Module-Build/t/lib/MBTest.pm +++ b/gnu/usr.bin/perl/cpan/Module-Build/t/lib/MBTest.pm @@ -12,6 +12,7 @@ use File::Path (); BEGIN { # Environment variables which might effect our testing my @delete_env_keys = qw( + HOME DEVEL_COVER_OPTIONS MODULEBUILDRC PERL_MB_OPT @@ -54,12 +55,10 @@ BEGIN { my $t_lib = File::Spec->catdir('t', 'bundled'); push @INC, $t_lib; # Let user's installed version override - if ($ENV{PERL_CORE}) { - # We change directories, so expand @INC and $^X to absolute paths - # Also add . - @INC = (map(File::Spec->rel2abs($_), @INC), "."); - $^X = File::Spec->rel2abs($^X); - } + # We change directories, so expand @INC and $^X to absolute paths + # Also add . + @INC = (map(File::Spec->rel2abs($_), @INC), "."); + $^X = File::Spec->rel2abs($^X); } use Exporter; @@ -96,7 +95,11 @@ __PACKAGE__->export(scalar caller, @extra_exports); # always return to the current directory { - my $cwd = File::Spec->rel2abs(Cwd::cwd); + my $cwd; + # must be done in BEGIN because tmpdir uses it in BEGIN for $ENV{HOME} + BEGIN { + $cwd = File::Spec->rel2abs(Cwd::cwd); + } sub original_cwd { return $cwd } @@ -123,6 +126,10 @@ sub tmpdir { return File::Temp::tempdir('MB-XXXXXXXX', CLEANUP => 1, DIR => $dir, @args); } +BEGIN { + $ENV{HOME} = tmpdir; # don't want .modulebuildrc or other things interfering +} + sub save_handle { my ($handle, $subr) = @_; my $outfile = File::Spec->catfile(File::Spec->tmpdir, temp_file_name()); @@ -201,6 +208,9 @@ sub check_compiler { my $have_c_compiler; stderr_of( sub {$have_c_compiler = $mb->have_c_compiler} ); + # XXX link_executable() is not yet implemented for Windows + # and noexec tmpdir is irrelevant on Windows + return ($have_c_compiler, 1) if $^O eq "MSWin32"; # check noexec tmpdir my $tmp_exec; diff --git a/gnu/usr.bin/perl/cpan/Module-Build/t/lib/Module/Signature.pm b/gnu/usr.bin/perl/cpan/Module-Build/t/lib/Module/Signature.pm new file mode 100644 index 00000000000..2d58f7d6dd0 --- /dev/null +++ b/gnu/usr.bin/perl/cpan/Module-Build/t/lib/Module/Signature.pm @@ -0,0 +1,11 @@ +package Module::Signature; # mocked +use strict; +use warnings; +our $VERSION = 999; + +sub sign { + open my $fh, ">", "SIGNATURE"; + print {$fh} "SIGNATURE"; +} + +1; diff --git a/gnu/usr.bin/perl/cpan/Module-Build/t/lib/Software/License/VaporWare.pm b/gnu/usr.bin/perl/cpan/Module-Build/t/lib/Software/License/VaporWare.pm new file mode 100644 index 00000000000..80d9fa5e784 --- /dev/null +++ b/gnu/usr.bin/perl/cpan/Module-Build/t/lib/Software/License/VaporWare.pm @@ -0,0 +1,17 @@ +use strict; +use warnings; + +package Software::License::VaporWare; +our $VERSION = '0.001'; + +use Software::License; +our @ISA = qw/Software::License/; + +sub name { 'VaporWare License' } +sub url { 'http://example.com/vaporware/' } +sub meta_name { 'unrestricted' } +sub meta2_name { 'unrestricted' } + +1; + + diff --git a/gnu/usr.bin/perl/cpan/Module-Build/t/metadata2.t b/gnu/usr.bin/perl/cpan/Module-Build/t/metadata2.t index a0fdd604d18..347a9a4d644 100755 --- a/gnu/usr.bin/perl/cpan/Module-Build/t/metadata2.t +++ b/gnu/usr.bin/perl/cpan/Module-Build/t/metadata2.t @@ -12,10 +12,7 @@ use DistGen; ############################## ACTION distmeta works without a MANIFEST file -SKIP: { - skip( 'YAML_support feature is not enabled', 4 ) - unless Module::Build::ConfigData->feature('YAML_support'); - +{ my $dist = DistGen->new( no_manifest => 1 )->chdir_in->regen; ok ! -e 'MANIFEST'; diff --git a/gnu/usr.bin/perl/cpan/Module-Build/t/mymeta.t b/gnu/usr.bin/perl/cpan/Module-Build/t/mymeta.t index 91a269027e6..d760edadbb7 100755 --- a/gnu/usr.bin/perl/cpan/Module-Build/t/mymeta.t +++ b/gnu/usr.bin/perl/cpan/Module-Build/t/mymeta.t @@ -3,10 +3,12 @@ use strict; use lib 't/lib'; use MBTest; -plan tests => 24; +use CPAN::Meta 2.110420; +use CPAN::Meta::YAML; +use Parse::CPAN::Meta 1.4401; +plan tests => 39; blib_load('Module::Build'); -blib_load('Module::Build::YAML'); my $tmp = MBTest->tmpdir; @@ -35,65 +37,100 @@ $dist->chdir_in; { ok( ! -e "META.yml", "META.yml doesn't exist before Build.PL runs" ); ok( ! -e "MYMETA.yml", "MYMETA.yml doesn't exist before Build.PL runs" ); + ok( ! -e "META.json", "META.json doesn't exist before Build.PL runs" ); + ok( ! -e "MYMETA.json", "MYMETA.json doesn't exist before Build.PL runs" ); my $output; $output = stdout_of sub { $dist->run_build_pl }; - like($output, qr/Creating new 'MYMETA.yml' with configuration results/, + like($output, qr/Created MYMETA\.yml and MYMETA\.json/, "Ran Build.PL and saw MYMETA.yml creation message" ); ok( -e "MYMETA.yml", "MYMETA.yml exists" ); + ok( -e "MYMETA.json", "MYMETA.json exists" ); } ######################### # Test interactions between META/MYMETA { - my $output = stdout_of sub { $dist->run_build('distmeta') }; - like($output, qr/Creating META.yml/, + my $output = stdout_stderr_of sub { $dist->run_build('distmeta') }; + like($output, qr/Created META\.yml and META\.json/, "Ran Build distmeta to create META.yml"); - my $meta = Module::Build::YAML->read('META.yml')->[0]; - my $mymeta = Module::Build::YAML->read('MYMETA.yml')->[0]; - is( delete $mymeta->{dynamic_config}, 0, - "MYMETA 'dynamic_config' is 0" + # regenerate MYMETA to pick up from META instead of creating from scratch + $output = stdout_of sub { $dist->run_build_pl }; + like($output, qr/Created MYMETA\.yml and MYMETA\.json/, + "Re-ran Build.PL and regenerated MYMETA.yml based on META.yml" ); - is_deeply( $meta, $mymeta, "Other generated MYMETA matches generated META" ); + + for my $suffix ( qw/.yml .json/ ) { + my $meta = Parse::CPAN::Meta->load_file("META$suffix"); + my $mymeta = Parse::CPAN::Meta->load_file("MYMETA$suffix"); + is( delete $meta->{dynamic_config}, 1, + "META$suffix 'dynamic_config' is 1" + ); + is( delete $mymeta->{dynamic_config}, 0, + "MYMETA$suffix 'dynamic_config' is 0" + ); + is_deeply( $mymeta, $meta, "Other generated MYMETA$suffix matches generated META$suffix" ) + or do { + require Data::Dumper; + diag "MYMETA:\n" . Data::Dumper::Dumper($mymeta) + . "META:\n" . Data::Dumper::Dumper($meta); + }; + } + $output = stdout_stderr_of sub { $dist->run_build('realclean') }; like( $output, qr/Cleaning up/, "Ran realclean"); ok( ! -e 'Build', "Build file removed" ); - ok( ! -e 'MYMETA.yml', "MYMETA file removed" ); + ok( ! -e 'MYMETA.yml', "MYMETA.yml file removed" ); + ok( ! -e 'MYMETA.json', "MYMETA.json file removed" ); # test that dynamic prereq is picked up + my $meta = Parse::CPAN::Meta->load_file("META.yml"); + my $meta2 = Parse::CPAN::Meta->load_file("META.json"); local $ENV{BUMP_PREREQ} = 1; $output = stdout_of sub { $dist->run_build_pl }; - like($output, qr/Creating new 'MYMETA.yml' with configuration results/, + like($output, qr/Created MYMETA\.yml and MYMETA\.json/, "Ran Build.PL with dynamic config" ); ok( -e "MYMETA.yml", "MYMETA.yml exists" ); - $mymeta = Module::Build::YAML->read('MYMETA.yml')->[0]; + ok( -e "MYMETA.json", "MYMETA.json exists" ); + my $mymeta = Parse::CPAN::Meta->load_file('MYMETA.yml'); + my $mymeta2 = Parse::CPAN::Meta->load_file('MYMETA.json'); isnt( $meta->{requires}{'File::Spec'}, $mymeta->{requires}{'File::Spec'}, - "MYMETA requires differs from META" + "MYMETA.yml requires differs from META.yml" + ); + isnt( $meta2->{prereqs}{runtime}{requires}{'File::Spec'}, + $mymeta2->{prereqs}{runtime}{requires}{'File::Spec'}, + "MYMETA.json requires differs from META.json" ); $output = stdout_stderr_of sub { $dist->run_build('realclean') }; like( $output, qr/Cleaning up/, "Ran realclean"); ok( ! -e 'Build', "Build file removed" ); ok( ! -e 'MYMETA.yml', "MYMETA file removed" ); + ok( ! -e 'MYMETA.json', "MYMETA file removed" ); # manually change META and check that changes are preserved $meta->{author} = ['John Gault']; - ok( Module::Build::YAML->new($meta)->write('META.yml'), + $meta2->{author} = ['John Gault']; + ok( CPAN::Meta::YAML->new($meta)->write('META.yml'), "Wrote manually modified META.yml" ); + ok( CPAN::Meta->new( $meta2 )->save('META.json'), + "Wrote manually modified META.json" ); $output = stdout_of sub { $dist->run_build_pl }; - like($output, qr/Creating new 'MYMETA.yml' with configuration results/, + like($output, qr/Created MYMETA\.yml and MYMETA\.json/, "Ran Build.PL" ); - my $mymeta2 = Module::Build::YAML->read('MYMETA.yml')->[0]; + $mymeta = Parse::CPAN::Meta->load_file('MYMETA.yml'); + $mymeta2 = Parse::CPAN::Meta->load_file('MYMETA.json'); + is_deeply( $mymeta->{author}, [ 'John Gault' ], + "MYMETA.yml preserved META.yml modifications" + ); is_deeply( $mymeta2->{author}, [ 'John Gault' ], - "MYMETA preserved META modifications" + "MYMETA.json preserved META.json modifications" ); - - } ######################### @@ -112,11 +149,12 @@ $dist->chdir_in; { my $output = stdout_of sub { $dist->run_build_pl }; - like($output, qr/Creating new 'MYMETA.yml' with configuration results/, + like($output, qr/Created MYMETA\.yml and MYMETA\.json/, "Ran Build.PL and saw MYMETA.yml creation message" ); $output = stdout_stderr_of sub { $dist->run_build('distclean') }; ok( ! -f 'MYMETA.yml', "No MYMETA.yml after distclean" ); + ok( ! -f 'MYMETA.json', "No MYMETA.json after distclean" ); ok( ! -f 'MANIFEST.SKIP', "No MANIFEST.SKIP after distclean" ); } diff --git a/gnu/usr.bin/perl/cpan/Module-Build/t/properties/dist_suffix.t b/gnu/usr.bin/perl/cpan/Module-Build/t/properties/dist_suffix.t new file mode 100644 index 00000000000..aaee1126691 --- /dev/null +++ b/gnu/usr.bin/perl/cpan/Module-Build/t/properties/dist_suffix.t @@ -0,0 +1,33 @@ +# sample.t -- a sample test file for Module::Build + +use strict; +use lib 't/lib'; +use MBTest; +use DistGen; + +plan tests => 2; + +# Ensure any Module::Build modules are loaded from correct directory +blib_load('Module::Build'); + +#--------------------------------------------------------------------------# +# Create test distribution +#--------------------------------------------------------------------------# + +use DistGen; +my $dist = DistGen->new( name => 'Simple::Name' ); + +$dist->change_build_pl( + module_name => 'Simple::Name', + dist_suffix => 'SUFFIX', +)->regen; + +$dist->chdir_in; + +my $mb = $dist->new_from_context(); +isa_ok( $mb, "Module::Build" ); +is( $mb->dist_dir, "Simple-Name-0.01-SUFFIX", + "dist_suffix set correctly" +); + +# vim:ts=2:sw=2:et:sta:sts=2 diff --git a/gnu/usr.bin/perl/cpan/Module-Build/t/properties/license.t b/gnu/usr.bin/perl/cpan/Module-Build/t/properties/license.t new file mode 100644 index 00000000000..db63b3951bb --- /dev/null +++ b/gnu/usr.bin/perl/cpan/Module-Build/t/properties/license.t @@ -0,0 +1,66 @@ +use strict; +use lib 't/lib'; +use MBTest; +use DistGen; + +plan 'no_plan'; + +# Ensure any Module::Build modules are loaded from correct directory +blib_load('Module::Build'); + +#--------------------------------------------------------------------------# +# Create test distribution +#--------------------------------------------------------------------------# + +{ + my $dist = DistGen->new( + name => 'Simple::Name', + version => '0.01', + license => 'perl' + ); + + $dist->regen; + $dist->chdir_in; + + my $mb = $dist->new_from_context(); + isa_ok( $mb, "Module::Build" ); + is( $mb->license, 'perl', + "license 'perl' is valid" + ); + + my $meta = $mb->get_metadata( fatal => 0 ); + + is( $meta->{license} => 'perl', "META license will be 'perl'" ); + is( $meta->{resources}{license}, "http://dev.perl.org/licenses/", + "META license URL is correct" + ); + +} + +{ + my $dist = DistGen->new( + name => 'Simple::Name', + version => '0.01', + license => 'VaporWare' + ); + + $dist->regen; + $dist->chdir_in; + + my $mb = $dist->new_from_context(); + isa_ok( $mb, "Module::Build" ); + is( $mb->license, 'VaporWare', + "license 'VaporWare' is valid" + ); + + my $meta = $mb->get_metadata( fatal => 0 ); + + is( $meta->{license} => 'unrestricted', "META license will be 'unrestricted'" ); + is( $meta->{resources}{license}, "http://example.com/vaporware/", + "META license URL is correct" + ); + +} + +# Test with alpha number +# vim:ts=2:sw=2:et:sta:sts=2 diff --git a/gnu/usr.bin/perl/cpan/Module-Build/t/properties/release_status.t b/gnu/usr.bin/perl/cpan/Module-Build/t/properties/release_status.t new file mode 100644 index 00000000000..45c7f3381cb --- /dev/null +++ b/gnu/usr.bin/perl/cpan/Module-Build/t/properties/release_status.t @@ -0,0 +1,204 @@ +use strict; +use lib 't/lib'; +use MBTest; +use DistGen; + +if ( $] lt 5.008001 ) { + plan skip_all => "dotted-version numbers are buggy before 5.8.1"; +} else { + plan 'no_plan'; +} + +# Ensure any Module::Build modules are loaded from correct directory +blib_load('Module::Build'); + +#--------------------------------------------------------------------------# +# Create test distribution +#--------------------------------------------------------------------------# + +{ + my $dist = DistGen->new( name => 'Simple::Name', version => '0.01' ); + + $dist->change_build_pl( + module_name => 'Simple::Name', + )->regen; + + $dist->chdir_in; + + my $mb = $dist->new_from_context(); + isa_ok( $mb, "Module::Build" ); + is( $mb->release_status, "stable", + "regular version has release_status 'stable'" + ); +} + +{ + my $dist = DistGen->new( name => 'Simple::Name', version => 'v1.2.3' ); + + $dist->change_build_pl( + module_name => 'Simple::Name', + )->regen; + + $dist->chdir_in; + + my $mb = $dist->new_from_context(); + isa_ok( $mb, "Module::Build" ); + is( $mb->release_status, "stable", + "dotted-decimal version has release_status 'stable'" + ); +} + +{ + my $dist = DistGen->new( name => 'Simple::Name', version => q{'0.01_01'} ); + + $dist->change_build_pl( + module_name => 'Simple::Name', + )->regen; + + $dist->chdir_in; + + my $mb = $dist->new_from_context(); + isa_ok( $mb, "Module::Build" ); + is( $mb->release_status, "testing", + "alpha version has release_status 'testing'" + ); +} + +{ + my $dist = DistGen->new( name => 'Simple::Name', version => 'v1.2.3_1' ); + + $dist->change_build_pl( + module_name => 'Simple::Name', + )->regen; + + $dist->chdir_in; + + my $mb = $dist->new_from_context(); + isa_ok( $mb, "Module::Build" ); + is( $mb->release_status, "testing", + "dotted alpha version has release_status 'testing'" + ); +} + +{ + my $dist = DistGen->new( name => 'Simple::Name', version => q{'0.01_01'} ); + + $dist->change_build_pl( + module_name => 'Simple::Name', + release_status => 'unstable', + )->regen; + + $dist->chdir_in; + + my $mb = $dist->new_from_context(); + isa_ok( $mb, "Module::Build" ); + is( $mb->release_status, "unstable", + "explicit 'unstable' keeps release_status 'unstable'" + ); +} + +{ + my $dist = DistGen->new( name => 'Simple::Name', version => '0.01' ); + + $dist->change_build_pl( + module_name => 'Simple::Name', + release_status => 'testing', + )->regen; + + $dist->chdir_in; + + my $mb = $dist->new_from_context(); + isa_ok( $mb, "Module::Build" ); + is( $mb->dist_suffix, "TRIAL", + "regular version marked 'testing' gets 'TRIAL' suffix" + ); +} + +{ + my $dist = DistGen->new( name => 'Simple::Name', version => 'v1.2.3' ); + + $dist->change_build_pl( + module_name => 'Simple::Name', + release_status => 'testing', + )->regen; + + $dist->chdir_in; + + my $mb = $dist->new_from_context(); + isa_ok( $mb, "Module::Build" ); + is( $mb->dist_suffix, "TRIAL", + "dotted version marked 'testing' gets 'TRIAL' suffix" + ); +} + +{ + my $dist = DistGen->new( name => 'Simple::Name', version => '0.01' ); + + $dist->change_build_pl( + module_name => 'Simple::Name', + release_status => 'unstable', + )->regen; + + $dist->chdir_in; + + my $mb = $dist->new_from_context(); + isa_ok( $mb, "Module::Build" ); + is( $mb->dist_suffix, "TRIAL", + "regular version marked 'unstable' gets 'TRIAL' suffix" + ); +} + +{ + my $dist = DistGen->new( name => 'Simple::Name', version => '0.01' ); + + $dist->change_build_pl( + module_name => 'Simple::Name', + release_status => 'beta', + )->regen; + + $dist->chdir_in; + + my $output = stdout_stderr_of sub { $dist->run_build_pl() }; + like( $output, qr/Illegal value 'beta' for release_status/i, + "Got error message for illegal release_status" + ); +} + +{ + my $dist = DistGen->new( name => 'Simple::Name', version => q{'0.01_01'} ); + + $dist->change_build_pl( + module_name => 'Simple::Name', + release_status => 'stable', + )->regen; + + $dist->chdir_in; + + my $output = stdout_stderr_of sub { $dist->run_build_pl() }; + like( $output, qr/Illegal value 'stable' with version '0.01_01'/i, + "Got error message for illegal 'stable' with alpha version" + ); +} + +{ + my $dist = DistGen->new( name => 'Simple::Name', version => q{'0.01_01'} ); + + $dist->change_build_pl( + module_name => 'Simple::Name', + dist_version => '1.23beta1', + )->regen; + + $dist->chdir_in; + + my $mb = $dist->new_from_context(); + isa_ok( $mb, "Module::Build" ); + is( $mb->dist_suffix, "", + "non-standard dist_version does not get a suffix" + ); + is( $mb->release_status, "stable", + "non-standard dist_version defaults to stable release_status" + ); +} + +# Test with alpha number +# vim:ts=2:sw=2:et:sta:sts=2 diff --git a/gnu/usr.bin/perl/cpan/Module-Build/t/properties/requires.t b/gnu/usr.bin/perl/cpan/Module-Build/t/properties/requires.t new file mode 100644 index 00000000000..72a2e6d9aba --- /dev/null +++ b/gnu/usr.bin/perl/cpan/Module-Build/t/properties/requires.t @@ -0,0 +1,54 @@ +# sample.t -- a sample test file for Module::Build + +use strict; +use lib 't/lib'; +use MBTest; +use DistGen; + +plan tests => 4; + +# Ensure any Module::Build modules are loaded from correct directory +blib_load('Module::Build'); + +my ($dist, $mb, $prereqs); + +#--------------------------------------------------------------------------# +# try undefined prereq version +#--------------------------------------------------------------------------# + +$dist = DistGen->new( name => 'Simple::Requires' ); + +$dist->change_build_pl( + module_name => 'Simple::Requires', + requires => { + 'File::Basename' => undef, + }, +)->regen; + +$dist->chdir_in; + +$mb = $dist->new_from_context(); +isa_ok( $mb, "Module::Build" ); + +$prereqs = $mb->_normalize_prereqs; +is($prereqs->{requires}{'File::Basename'}, 0, "undef prereq converted to 0"); + +#--------------------------------------------------------------------------# +# try empty string prereq version +#--------------------------------------------------------------------------# + +$dist->change_build_pl( + module_name => 'Simple::Requires', + requires => { + 'File::Basename' => '', + }, +)->regen; + +$mb = $dist->new_from_context(); +isa_ok( $mb, "Module::Build" ); + +$prereqs = $mb->_normalize_prereqs; +is($prereqs->{requires}{'File::Basename'}, 0, "empty string prereq converted to 0"); + + +# vim:ts=2:sw=2:et:sta:sts=2 diff --git a/gnu/usr.bin/perl/cpan/Module-Build/t/properties/share_dir.t b/gnu/usr.bin/perl/cpan/Module-Build/t/properties/share_dir.t index 1d81a0aa45c..f1cda13429a 100755 --- a/gnu/usr.bin/perl/cpan/Module-Build/t/properties/share_dir.t +++ b/gnu/usr.bin/perl/cpan/Module-Build/t/properties/share_dir.t @@ -9,7 +9,7 @@ use File::Spec::Functions qw/catdir catfile/; # Begin testing #--------------------------------------------------------------------------# -plan tests => 21; +plan tests => 23; blib_load('Module::Build'); @@ -43,11 +43,19 @@ ok( ! exists $mb->{properties}{requires}{'File::ShareDir'}, $dist->add_file('share/foo.txt',<< '---'); This is foo.txt --- +$dist->add_file('share/subdir/share/anotherbar.txt',<< '---'); +This is anotherbar.txt in a subdir - test for a bug in M::B 0.38 when full path contains 'share/.../*share/...' subdir +--- +$dist->add_file('share/subdir/whatever/anotherfoo.txt',<< '---'); +This is anotherfoo.txt in a subdir - this shoud work on M::B 0.38 +--- $dist->add_file('other/share/bar.txt',<< '---'); This is bar.txt --- $dist->regen; ok( -e catfile(qw/share foo.txt/), "Created 'share' directory" ); +ok( -d catfile(qw/share subdir share/), "Created 'share/subdir/share' directory" ); +ok( -d catfile(qw/share subdir whatever/), "Created 'share/subdir/whatever' directory" ); ok( -e catfile(qw/other share bar.txt/), "Created 'other/share' directory" ); # Check default when share_dir is not given @@ -163,6 +171,8 @@ is_deeply( $mb->share_dir, is_deeply( $mb->_find_share_dir_files, { "share/foo.txt" => "dist/Simple-Share/foo.txt", + "share/subdir/share/anotherbar.txt" => "dist/Simple-Share/subdir/share/anotherbar.txt", + "share/subdir/whatever/anotherfoo.txt" => "dist/Simple-Share/subdir/whatever/anotherfoo.txt", "other/share/bar.txt" => "module/Simple-Share/bar.txt", }, "share_dir filemap for copying to lib complete" @@ -187,6 +197,8 @@ skip 'filename case not necessarily preserved', 1 if $^O eq 'VMS'; is_deeply( [ sort @$share_list ], [ 'blib/lib/auto/share/dist/Simple-Share/foo.txt', + 'blib/lib/auto/share/dist/Simple-Share/subdir/share/anotherbar.txt', + 'blib/lib/auto/share/dist/Simple-Share/subdir/whatever/anotherfoo.txt', 'blib/lib/auto/share/module/Simple-Share/bar.txt', ], "share_dir files copied to blib" @@ -217,6 +229,8 @@ skip 'filename case not necessarily preserved', 1 if $^O eq 'VMS'; is_deeply( [ sort @$share_list ], [ "$temp_install/lib/perl5/auto/share/dist/Simple-Share/foo.txt", + "$temp_install/lib/perl5/auto/share/dist/Simple-Share/subdir/share/anotherbar.txt", + "$temp_install/lib/perl5/auto/share/dist/Simple-Share/subdir/whatever/anotherfoo.txt", "$temp_install/lib/perl5/auto/share/module/Simple-Share/bar.txt", ], "share_dir files correctly installed" diff --git a/gnu/usr.bin/perl/cpan/Module-Build/t/runthrough.t b/gnu/usr.bin/perl/cpan/Module-Build/t/runthrough.t index 9e8d52ed11c..1c0edf4402a 100755 --- a/gnu/usr.bin/perl/cpan/Module-Build/t/runthrough.t +++ b/gnu/usr.bin/perl/cpan/Module-Build/t/runthrough.t @@ -6,7 +6,6 @@ use MBTest tests => 29; blib_load('Module::Build'); blib_load('Module::Build::ConfigData'); -my $have_yaml = Module::Build::ConfigData->feature('YAML_support'); ######################### @@ -106,18 +105,16 @@ ok grep {$_ eq 'save_out' } $mb->cleanup; } } -SKIP: { - skip( 'YAML_support feature is not enabled', 7 ) unless $have_yaml; - +{ my $output = eval { - stdout_of( sub { $mb->dispatch('disttest') } ) + stdout_stderr_of( sub { $mb->dispatch('disttest') } ) }; is $@, ''; # After a test, the distdir should contain a blib/ directory ok -e File::Spec->catdir('Simple-0.01', 'blib'); - eval {$mb->dispatch('distdir')}; + stdout_stderr_of ( sub { eval {$mb->dispatch('distdir')} } ); is $@, ''; # The 'distdir' should contain a lib/ directory diff --git a/gnu/usr.bin/perl/cpan/Module-Build/t/script_dist.t b/gnu/usr.bin/perl/cpan/Module-Build/t/script_dist.t index 7fd82d9547a..fa02b49d33f 100755 --- a/gnu/usr.bin/perl/cpan/Module-Build/t/script_dist.t +++ b/gnu/usr.bin/perl/cpan/Module-Build/t/script_dist.t @@ -7,6 +7,7 @@ use lib 't/lib'; use MBTest 'no_plan'; use DistGen qw(undent); +use CPAN::Meta::YAML; blib_load('Module::Build'); blib_load('Module::Build::ConfigData'); @@ -39,7 +40,7 @@ my %details = ( dist_version => '0.01', ); my %meta_provides = ( - 'bin-foo' => { + 'foo' => { file => 'bin/foo', version => '0.01', } @@ -68,13 +69,11 @@ is($mb->dist_name, 'bin-foo'); is($mb->dist_version, '0.01'); is_deeply($mb->dist_author, ['A. U. Thor, a.u.thor@a.galaxy.far.far.away']); -ok $mb->dispatch('distmeta'); - -SKIP: { - skip( 'YAML_support feature is not enabled', 1 ) - unless Module::Build::ConfigData->feature('YAML_support'); - require YAML::Tiny; - my $yml = YAML::Tiny::LoadFile('META.yml'); - is_deeply($yml->{provides}, \%meta_provides); -} +my $result; +stdout_stderr_of( sub { $result = $mb->dispatch('distmeta') } ); +ok $result; + +my $yml = CPAN::Meta::YAML->read_string(slurp('META.yml'))->[0]; +is_deeply($yml->{provides}, \%meta_provides); + $dist->chdir_original if $dist->did_chdir; diff --git a/gnu/usr.bin/perl/cpan/Module-Build/t/tilde.t b/gnu/usr.bin/perl/cpan/Module-Build/t/tilde.t index a5ed79083b0..04f0210f30b 100755 --- a/gnu/usr.bin/perl/cpan/Module-Build/t/tilde.t +++ b/gnu/usr.bin/perl/cpan/Module-Build/t/tilde.t @@ -46,19 +46,20 @@ SKIP: { unless (defined $home) { my @info = eval { getpwuid $> }; - skip "No home directory for tilde-expansion tests", 15 if $@; + skip "No home directory for tilde-expansion tests", 15 if $@ + or !defined $info[7]; $home = $info[7]; } is( run_sample( $p => '~' )->$p(), $home ); - is( run_sample( $p => '~/foo' )->$p(), "$home/foo" ); + is( run_sample( $p => '~/fooxzy' )->$p(), "$home/fooxzy" ); - is( run_sample( $p => '~/ foo')->$p(), "$home/ foo" ); + is( run_sample( $p => '~/ fooxzy')->$p(), "$home/ fooxzy" ); is( run_sample( $p => '~/fo o')->$p(), "$home/fo o" ); - is( run_sample( $p => 'foo~' )->$p(), 'foo~' ); + is( run_sample( $p => 'fooxzy~' )->$p(), 'fooxzy~' ); is( run_sample( prefix => '~' )->prefix, $home ); @@ -89,24 +90,25 @@ SKIP: { skip "On OS/2 EMX all users are equal", 2 if $^O eq 'os2'; is( run_sample( $p => '~~' )->$p(), '~~' ); - is( run_sample( $p => '~ foo' )->$p(), '~ foo' ); + is( run_sample( $p => '~ fooxzy' )->$p(), '~ fooxzy' ); } # Again, with named users SKIP: { my @info = eval { getpwuid $> }; - skip "No home directory for tilde-expansion tests", 1 if $@; + skip "No home directory for tilde-expansion tests", 1 if $@ + or !defined $info[7] or !defined $info[0]; my ($me, $home) = @info[0,7]; - my $expected = "$home/foo"; + my $expected = "$home/fooxzy"; if ($^O eq 'VMS') { # Convert the path to UNIX format and trim off the trailing slash $home = VMS::Filespec::unixify($home); $home =~ s#/$##; - $expected = $home . '/../[^/]+' . '/foo'; + $expected = $home . '/../[^/]+' . '/fooxzy'; } - like( run_sample( $p => "~$me/foo")->$p(), qr($expected)i ); + like( run_sample( $p => "~$me/fooxzy")->$p(), qr(\Q$expected\E)i ); } |