⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 metadata.t

📁 source of perl for linux application,
💻 T
📖 第 1 页 / 共 2 页
字号:
#!/usr/bin/perl -wuse strict;use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';use MBTest tests => 49;use Cwd ();my $cwd = Cwd::cwd;my $tmp = MBTest->tmpdir;use Module::Build;use Module::Build::ConfigData;my %metadata =   (   module_name   => 'Simple',   dist_version  => '3.14159265',   dist_author   => [ 'Simple Simon <ss\@somewhere.priv>' ],   dist_abstract => 'Something interesting',   license       => 'perl',   meta_add => {		keywords  => [qw(super duper something)],		resources => {homepage => 'http://foo.example.com'},	       },  );use DistGen;my $dist = DistGen->new( dir => $tmp );$dist->change_build_pl( \%metadata );$dist->regen;my $simple_file = 'lib/Simple.pm';my $simple2_file = 'lib/Simple2.pm';   #TODO:   # Traditional VMS will return the file in in lower case, and is_deeply   # does exact case comparisons.   # When ODS-5 support is active for preserved case file names, this will   # need to be changed.   if ($^O eq 'VMS') {       $simple_file = lc($simple_file);       $simple2_file = lc($simple2_file);   }chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";use Module::Build;my $mb = Module::Build->new_from_context;#################################################### Test for valid META.yml{  my $node = $mb->prepare_metadata( {} );  # exists() doesn't seem to work here  is $node->{name}, $metadata{module_name};  is $node->{version}, $metadata{dist_version};  is $node->{abstract}, $metadata{dist_abstract};  is_deeply $node->{author}, $metadata{dist_author};  is $node->{license}, $metadata{license};  like $node->{generated_by}, qr{Module::Build};  ok defined( $node->{'meta-spec'}{version} ),      "'meta-spec' -> 'version' field present in META.yml";  ok defined( $node->{'meta-spec'}{url} ),      "'meta-spec' -> 'url' field present in META.yml";  is_deeply $node->{keywords}, $metadata{meta_add}{keywords};  is_deeply $node->{resources}, $metadata{meta_add}{resources};}$dist->clean;#################################################### Tests to ensure that the correct packages and versions are# recorded for the 'provides' field of META.ymlmy $provides; # Used a bunch of times belowsub 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()->prepare_metadata()->{provides};  is $provides->{'Simple'}{version}, '0.60.128', "Check version";  is $provides->{'Simple::Simon'}{version}, '0.61.129', "Check version";  is ref($provides->{'Simple'}{version}), '', "Versions from prepare_metadata() aren't refs";  is ref($provides->{'Simple::Simon'}{version}), '', "Versions from prepare_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?like( $err, qr/already declared/, '  with conflicting versions reported' );# (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?like( $err, qr/already declared/, '  with conflicting versions reported' );############################## 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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -