diff options
Diffstat (limited to 'cpan/Module-Build/t/metadata.t')
-rw-r--r-- | cpan/Module-Build/t/metadata.t | 523 |
1 files changed, 3 insertions, 520 deletions
diff --git a/cpan/Module-Build/t/metadata.t b/cpan/Module-Build/t/metadata.t index d728a681e5..ce6d208645 100644 --- a/cpan/Module-Build/t/metadata.t +++ b/cpan/Module-Build/t/metadata.t @@ -2,7 +2,7 @@ use strict; use lib 't/lib'; -use MBTest tests => 52; +use MBTest tests => 14; blib_load('Module::Build'); blib_load('Module::Build::ConfigData'); @@ -16,7 +16,7 @@ my %metadata = dist_author => [ 'Simple Simon <ss\@somewhere.priv>' ], dist_abstract => 'Something interesting', test_requires => { - 'Test::More' => 0.98, + 'Test::More' => 0.49, }, license => 'perl', meta_add => { @@ -84,7 +84,7 @@ my $mb = Module::Build->new_from_context; is $node->{license}, $metadata{license}; is_deeply $node->{configure_requires}, $mb_config_req, 'Add M::B to configure_requires'; is_deeply $node->{test_requires}, { - 'Test::More' => '0.98', + 'Test::More' => '0.49', }, 'Test::More was required by ->new'; like $node->{generated_by}, qr{Module::Build}; ok defined( $node->{'meta-spec'}{version} ), @@ -107,520 +107,3 @@ my $mb = Module::Build->new_from_context; $dist->clean; - -################################################## -# -# Tests to ensure that the correct packages and versions are -# recorded for the 'provides' field of META.yml - -my $provides; # Used a bunch of times below - -sub new_build { return Module::Build->new_from_context( quiet => 1, @_ ) } - -############################## Single Module - -# File with corresponding package (w/ or w/o version) -# Simple.pm => Simple v1.23 - -$dist->change_file( 'lib/Simple.pm', <<'---' ); -package Simple; -$VERSION = '1.23'; ---- -$dist->regen( clean => 1 ); -$mb = new_build(); -is_deeply($mb->find_dist_packages, - {'Simple' => {file => $simple_file, - version => '1.23'}}); - -$dist->change_file( 'lib/Simple.pm', <<'---' ); -package Simple; ---- -$dist->regen( clean => 1 ); -$mb = new_build(); -is_deeply($mb->find_dist_packages, - {'Simple' => {file => $simple_file}}); - -# File with no corresponding package (w/ or w/o version) -# Simple.pm => Foo::Bar v1.23 - -$dist->change_file( 'lib/Simple.pm', <<'---' ); -package Foo::Bar; -$VERSION = '1.23'; ---- -$dist->regen( clean => 1 ); -$mb = new_build(); -is_deeply($mb->find_dist_packages, - {'Foo::Bar' => { file => $simple_file, - version => '1.23' }}); - -$dist->change_file( 'lib/Simple.pm', <<'---' ); -package Foo::Bar; ---- -$dist->regen( clean => 1 ); -$mb = new_build(); -is_deeply($mb->find_dist_packages, - {'Foo::Bar' => { file => $simple_file}}); - - -# Single file with multiple differing packages (w/ or w/o version) -# Simple.pm => Simple -# Simple.pm => Foo::Bar - -$dist->change_file( 'lib/Simple.pm', <<'---' ); -package Simple; -$VERSION = '1.23'; -package Foo::Bar; -$VERSION = '1.23'; ---- -$dist->regen( clean => 1 ); -$mb = new_build(); -is_deeply($mb->find_dist_packages, - {'Simple' => { file => $simple_file, - version => '1.23' }, - 'Foo::Bar' => { file => $simple_file, - version => '1.23' }}); - -{ - $dist->change_file( 'lib/Simple.pm', <<'---' ); -package Simple; -$VERSION = version->new('0.60.' . (qw$Revision: 128 $)[1]); -package Simple::Simon; -$VERSION = version->new('0.61.' . (qw$Revision: 129 $)[1]); ---- - $dist->regen; - my $provides = new_build()->get_metadata()->{provides}; - is $provides->{'Simple'}{version}, 'v0.60.128', "Check version"; - is $provides->{'Simple::Simon'}{version}, 'v0.61.129', "Check version"; - is ref($provides->{'Simple'}{version}), '', "Versions from get_metadata() aren't refs"; - is ref($provides->{'Simple::Simon'}{version}), '', "Versions from get_metadata() aren't refs"; -} - - -# Single file with multiple differing packages, no corresponding package -# Simple.pm => Foo -# Simple.pm => Foo::Bar - -$dist->change_file( 'lib/Simple.pm', <<'---' ); -package Foo; -$VERSION = '1.23'; -package Foo::Bar; -$VERSION = '1.23'; ---- -$dist->regen( clean => 1 ); -$mb = new_build(); -is_deeply($mb->find_dist_packages, - {'Foo' => { file => $simple_file, - version => '1.23' }, - 'Foo::Bar' => { file => $simple_file, - version => '1.23' }}); - - -# Single file with same package appearing multiple times, no version -# only record a single instance -# Simple.pm => Simple -# Simple.pm => Simple - -$dist->change_file( 'lib/Simple.pm', <<'---' ); -package Simple; -package Simple; ---- -$dist->regen( clean => 1 ); -$mb = new_build(); -is_deeply($mb->find_dist_packages, - {'Simple' => { file => $simple_file }}); - - -# Single file with same package appearing multiple times, single -# version 1st package: -# Simple.pm => Simple v1.23 -# Simple.pm => Simple - -$dist->change_file( 'lib/Simple.pm', <<'---' ); -package Simple; -$VERSION = '1.23'; -package Simple; ---- -$dist->regen( clean => 1 ); -$mb = new_build(); -is_deeply($mb->find_dist_packages, - {'Simple' => { file => $simple_file, - version => '1.23' }}); - - -# Single file with same package appearing multiple times, single -# version 2nd package -# Simple.pm => Simple -# Simple.pm => Simple v1.23 - -$dist->change_file( 'lib/Simple.pm', <<'---' ); -package Simple; -package Simple; -$VERSION = '1.23'; ---- -$dist->regen( clean => 1 ); -$mb = new_build(); -is_deeply($mb->find_dist_packages, - {'Simple' => { file => $simple_file, - version => '1.23' }}); - - -# Single file with same package appearing multiple times, conflicting versions -# Simple.pm => Simple v1.23 -# Simple.pm => Simple v2.34 - -$dist->change_file( 'lib/Simple.pm', <<'---' ); -package Simple; -$VERSION = '1.23'; -package Simple; -$VERSION = '2.34'; ---- -$dist->regen( clean => 1 ); -my $err = ''; -$err = stderr_of( sub { $mb = new_build() } ); -$err = stderr_of( sub { $provides = $mb->find_dist_packages } ); -is_deeply($provides, - {'Simple' => { file => $simple_file, - version => '1.23' }}); # XXX should be 2.34? - - -# (Same as above three cases except with no corresponding package) -# Simple.pm => Foo v1.23 -# Simple.pm => Foo v2.34 - -$dist->change_file( 'lib/Simple.pm', <<'---' ); -package Foo; -$VERSION = '1.23'; -package Foo; -$VERSION = '2.34'; ---- -$dist->regen( clean => 1 ); -$err = stderr_of( sub { $mb = new_build() } ); -$err = stderr_of( sub { $provides = $mb->find_dist_packages } ); -is_deeply($provides, - {'Foo' => { file => $simple_file, - version => '1.23' }}); # XXX should be 2.34? - -# Missing version should not show up in provides as version "0" - -$dist->change_file( 'lib/Simple.pm', <<'---' ); -package Foo; -$VERSION = undef; -1; ---- -$dist->regen( clean => 1 ); -$err = stderr_of( sub { $mb = new_build() } ); -$err = stderr_of( sub { $provides = $mb->find_dist_packages } ); -is_deeply($provides, - {'Foo' => { file => $simple_file } }, - "undef \$VERSION is omitted from 'provides'" -); - -############################## Multiple Modules - -# Multiple files with same package, no version -# Simple.pm => Simple -# Simple2.pm => Simple - -$dist->change_file( 'lib/Simple.pm', <<'---' ); -package Simple; ---- -$dist->add_file( 'lib/Simple2.pm', <<'---' ); -package Simple; ---- -$dist->regen( clean => 1 ); -$mb = new_build(); -is_deeply($mb->find_dist_packages, - {'Simple' => { file => $simple_file }}); -$dist->remove_file( 'lib/Simple2.pm' ); - - -# Multiple files with same package, single version in corresponding package -# Simple.pm => Simple v1.23 -# Simple2.pm => Simple - -$dist->change_file( 'lib/Simple.pm', <<'---' ); -package Simple; -$VERSION = '1.23'; ---- -$dist->add_file( 'lib/Simple2.pm', <<'---' ); -package Simple; ---- -$dist->regen( clean => 1 ); -$mb = new_build(); -is_deeply($mb->find_dist_packages, - {'Simple' => { file => $simple_file, - version => '1.23' }}); -$dist->remove_file( 'lib/Simple2.pm' ); - - -# Multiple files with same package, -# single version in non-corresponding package -# Simple.pm => Simple -# Simple2.pm => Simple v1.23 - -$dist->change_file( 'lib/Simple.pm', <<'---' ); -package Simple; ---- -$dist->add_file( 'lib/Simple2.pm', <<'---' ); -package Simple; -$VERSION = '1.23'; ---- -$dist->regen( clean => 1 ); -$mb = new_build(); -is_deeply($mb->find_dist_packages, - {'Simple' => { file => $simple2_file, - version => '1.23' }}); -$dist->remove_file( 'lib/Simple2.pm' ); - - -# Multiple files with same package, conflicting versions -# Simple.pm => Simple v1.23 -# Simple2.pm => Simple v2.34 - -$dist->change_file( 'lib/Simple.pm', <<'---' ); -package Simple; -$VERSION = '1.23'; ---- -$dist->add_file( 'lib/Simple2.pm', <<'---' ); -package Simple; -$VERSION = '2.34'; ---- -$dist->regen( clean => 1 ); -stderr_of( sub { $mb = new_build(); } ); -$err = stderr_of( sub { $provides = $mb->find_dist_packages } ); -is_deeply($provides, - {'Simple' => { file => $simple_file, - version => '1.23' }}); -like( $err, qr/Found conflicting versions for package/, - ' with conflicting versions reported' ); -$dist->remove_file( 'lib/Simple2.pm' ); - - -# Multiple files with same package, multiple agreeing versions -# Simple.pm => Simple v1.23 -# Simple2.pm => Simple v1.23 - -$dist->change_file( 'lib/Simple.pm', <<'---' ); -package Simple; -$VERSION = '1.23'; ---- -$dist->add_file( 'lib/Simple2.pm', <<'---' ); -package Simple; -$VERSION = '1.23'; ---- -$dist->regen( clean => 1 ); -$mb = new_build(); -$err = stderr_of( sub { $provides = $mb->find_dist_packages } ); -is_deeply($provides, - {'Simple' => { file => $simple_file, - version => '1.23' }}); -$dist->remove_file( 'lib/Simple2.pm' ); - - -############################################################ -# -# (Same as above five cases except with non-corresponding package) -# - -# Multiple files with same package, no version -# Simple.pm => Foo -# Simple2.pm => Foo - -$dist->change_file( 'lib/Simple.pm', <<'---' ); -package Foo; ---- -$dist->add_file( 'lib/Simple2.pm', <<'---' ); -package Foo; ---- -$dist->regen( clean => 1 ); -$mb = new_build(); -$provides = $mb->find_dist_packages; -ok( exists( $provides->{Foo} ) ); # it exist, can't predict which file -$dist->remove_file( 'lib/Simple2.pm' ); - - -# Multiple files with same package, version in first file -# Simple.pm => Foo v1.23 -# Simple2.pm => Foo - -$dist->change_file( 'lib/Simple.pm', <<'---' ); -package Foo; -$VERSION = '1.23'; ---- -$dist->add_file( 'lib/Simple2.pm', <<'---' ); -package Foo; ---- -$dist->regen( clean => 1 ); -$mb = new_build(); -is_deeply($mb->find_dist_packages, - {'Foo' => { file => $simple_file, - version => '1.23' }}); -$dist->remove_file( 'lib/Simple2.pm' ); - - -# Multiple files with same package, version in second file -# Simple.pm => Foo -# Simple2.pm => Foo v1.23 - -$dist->change_file( 'lib/Simple.pm', <<'---' ); -package Foo; ---- -$dist->add_file( 'lib/Simple2.pm', <<'---' ); -package Foo; -$VERSION = '1.23'; ---- -$dist->regen( clean => 1 ); -$mb = new_build(); -is_deeply($mb->find_dist_packages, - {'Foo' => { file => $simple2_file, - version => '1.23' }}); -$dist->remove_file( 'lib/Simple2.pm' ); - - -# Multiple files with same package, conflicting versions -# Simple.pm => Foo v1.23 -# Simple2.pm => Foo v2.34 - -$dist->change_file( 'lib/Simple.pm', <<'---' ); -package Foo; -$VERSION = '1.23'; ---- -$dist->add_file( 'lib/Simple2.pm', <<'---' ); -package Foo; -$VERSION = '2.34'; ---- -$dist->regen( clean => 1 ); -stderr_of( sub { $mb = new_build(); } ); -$err = stderr_of( sub { $provides = $mb->find_dist_packages } ); -# XXX Should 'Foo' exist ??? Can't predict values for file & version -ok( exists( $provides->{Foo} ) ); -like( $err, qr/Found conflicting versions for package/, - ' with conflicting versions reported' ); -$dist->remove_file( 'lib/Simple2.pm' ); - - -# Multiple files with same package, multiple agreeing versions -# Simple.pm => Foo v1.23 -# Simple2.pm => Foo v1.23 - -$dist->change_file( 'lib/Simple.pm', <<'---' ); -package Foo; -$VERSION = '1.23'; ---- -$dist->add_file( 'lib/Simple2.pm', <<'---' ); -package Foo; -$VERSION = '1.23'; ---- -$dist->regen( clean => 1 ); -$mb = new_build(); -$err = stderr_of( sub { $provides = $mb->find_dist_packages } ); -ok( exists( $provides->{Foo} ) ); -is( $provides->{Foo}{version}, '1.23' ); -ok( exists( $provides->{Foo}{file} ) ); # Can't predict which file -is( $err, '', ' no conflicts reported' ); -$dist->remove_file( 'lib/Simple2.pm' ); - -############################################################ -# Conflicts among primary & multiple alternatives - -# multiple files, conflicting version in corresponding file -$dist->change_file( 'lib/Simple.pm', <<'---' ); -package Simple; -$VERSION = '1.23'; ---- -$dist->add_file( 'lib/Simple2.pm', <<'---' ); -package Simple; -$VERSION = '2.34'; ---- -$dist->add_file( 'lib/Simple3.pm', <<'---' ); -package Simple; -$VERSION = '2.34'; ---- -$dist->regen( clean => 1 ); -$err = stderr_of( sub { - $mb = new_build(); -} ); -$err = stderr_of( sub { $provides = $mb->find_dist_packages } ); -is_deeply($provides, - {'Simple' => { file => $simple_file, - version => '1.23' }}); -like( $err, qr/Found conflicting versions for package/, - ' corresponding package conflicts with multiple alternatives' ); -$dist->remove_file( 'lib/Simple2.pm' ); -$dist->remove_file( 'lib/Simple3.pm' ); - -# multiple files, conflicting version in non-corresponding file -$dist->change_file( 'lib/Simple.pm', <<'---' ); -package Simple; -$VERSION = '1.23'; ---- -$dist->add_file( 'lib/Simple2.pm', <<'---' ); -package Simple; -$VERSION = '1.23'; ---- -$dist->add_file( 'lib/Simple3.pm', <<'---' ); -package Simple; -$VERSION = '2.34'; ---- -$dist->regen( clean => 1 ); -$err = stderr_of( sub { - $mb = new_build(); -} ); -$err = stderr_of( sub { $provides = $mb->find_dist_packages } ); -is_deeply($provides, - {'Simple' => { file => $simple_file, - version => '1.23' }}); -like( $err, qr/Found conflicting versions for package/, - ' only one alternative conflicts with corresponding package' ); -$dist->remove_file( 'lib/Simple2.pm' ); -$dist->remove_file( 'lib/Simple3.pm' ); - - -############################################################ -# Don't record private packages (beginning with underscore) -# Simple.pm => Simple::_private -# Simple.pm => Simple::_private::too - -$dist->change_file( 'lib/Simple.pm', <<'---' ); -package Simple; -$VERSION = '1.23'; -package Simple::_private; -$VERSION = '2.34'; -package Simple::_private::too; -$VERSION = '3.45'; ---- -$dist->regen( clean => 1 ); -$mb = new_build(); -is_deeply($mb->find_dist_packages, - {'Simple' => { file => $simple_file, - version => '1.23' }}); - - -############################################################ -# Files with no packages? - -# Simple.pm => <empty> - -$dist->change_file( 'lib/Simple.pm', '' ); -$dist->regen( clean => 1 ); -$mb = new_build(); -is_deeply( $mb->find_dist_packages, {} ); - -# Simple.pm => =pod..=cut (no package declaration) -$dist->change_file( 'lib/Simple.pm', <<'---' ); -=pod - -=head1 NAME - -Simple - Pure Documentation - -=head1 DESCRIPTION - -Doesn't do anything. - -=cut ---- -$dist->regen( clean => 1 ); -$mb = new_build(); -is_deeply($mb->find_dist_packages, {}); - |