This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update Module-Build to CPAN version 0.4200
[perl5.git] / cpan / Module-Build / t / metadata.t
CommitLineData
bb4e9162
YST
1#!/usr/bin/perl -w
2
3use strict;
10b84a45 4use lib 't/lib';
46de787b 5use MBTest tests => 14;
bb4e9162 6
613f422f
DG
7blib_load('Module::Build');
8blib_load('Module::Build::ConfigData');
bb4e9162 9
738349a8 10my $tmp = MBTest->tmpdir;
bb4e9162 11
53fc1c7e 12my %metadata =
7a827510
RGS
13 (
14 module_name => 'Simple',
15 dist_version => '3.14159265',
16 dist_author => [ 'Simple Simon <ss\@somewhere.priv>' ],
17 dist_abstract => 'Something interesting',
ee76e757 18 test_requires => {
46de787b 19 'Test::More' => 0.49,
ee76e757 20 },
7a827510
RGS
21 license => 'perl',
22 meta_add => {
23 keywords => [qw(super duper something)],
24 resources => {homepage => 'http://foo.example.com'},
25 },
26 );
bb4e9162
YST
27
28
29use DistGen;
30my $dist = DistGen->new( dir => $tmp );
7a827510 31$dist->change_build_pl( \%metadata );
bb4e9162
YST
32$dist->regen;
33
d1bd4ef0
JM
34my $simple_file = 'lib/Simple.pm';
35my $simple2_file = 'lib/Simple2.pm';
36
d1bd4ef0
JM
37 # Traditional VMS will return the file in in lower case, and is_deeply
38 # does exact case comparisons.
94410036
DG
39 # When ODS-5 support is active for preserved case file names we do not
40 # change the case.
d1bd4ef0 41 if ($^O eq 'VMS') {
94410036
DG
42 my $lower_case_expect = 1;
43 my $vms_efs_case = 0;
44 if (eval 'require VMS::Feature') {
45 $vms_efs_case = VMS::Feature::current("efs_case_preserve");
46 } else {
47 my $efs_case = $ENV{'DECC$EFS_CASE_PRESERVE'} || '';
48 $vms_efs_case = $efs_case =~ /^[ET1]/i;
49 }
50 $lower_case_expect = 0 if $vms_efs_case;
51 if ($lower_case_expect) {
52 $simple_file = lc($simple_file);
53 $simple2_file = lc($simple2_file);
54 }
d1bd4ef0
JM
55 }
56
57
738349a8 58$dist->chdir_in;
bb4e9162 59
bb4e9162
YST
60my $mb = Module::Build->new_from_context;
61
62##################################################
63#
64# Test for valid META.yml
65
7a827510 66{
23837600 67 my $mb_prereq = { 'Module::Build' => $Module::Build::VERSION };
53fc1c7e 68 my $mb_config_req = {
1ce5ed3e 69 'Module::Build' => sprintf '%2.2f', int($Module::Build::VERSION * 100)/100
cdbde1c3 70 };
7cf8bfc0
DG
71 my $node;
72 my $output = stdout_stderr_of( sub {
73 $node = $mb->get_metadata( auto => 1 );
74 });
75 like( $output, qr/Module::Build was not found in configure_requires/,
76 "saw warning about M::B not in configure_requires"
77 );
bb4e9162
YST
78
79 # exists() doesn't seem to work here
7a827510
RGS
80 is $node->{name}, $metadata{module_name};
81 is $node->{version}, $metadata{dist_version};
82 is $node->{abstract}, $metadata{dist_abstract};
83 is_deeply $node->{author}, $metadata{dist_author};
18b2aa6a
CBW
84 is_deeply $node->{license}, [ 'perl_5' ];
85 is_deeply $node->{prereqs}{configure}{requires}, $mb_config_req, 'Add M::B to configure_requires';
86 is_deeply $node->{prereqs}{test}{requires}, {
46de787b 87 'Test::More' => '0.49',
ee76e757 88 }, 'Test::More was required by ->new';
7a827510 89 like $node->{generated_by}, qr{Module::Build};
bb4e9162
YST
90 ok defined( $node->{'meta-spec'}{version} ),
91 "'meta-spec' -> 'version' field present in META.yml";
92 ok defined( $node->{'meta-spec'}{url} ),
93 "'meta-spec' -> 'url' field present in META.yml";
7a827510
RGS
94 is_deeply $node->{keywords}, $metadata{meta_add}{keywords};
95 is_deeply $node->{resources}, $metadata{meta_add}{resources};
bb4e9162
YST
96}
97
23837600
DG
98{
99 my $mb_prereq = { 'Module::Build' => 0 };
100 $mb->configure_requires( $mb_prereq );
7cf8bfc0 101 my $node = $mb->get_metadata( auto => 1 );
23837600
DG
102
103
104 # exists() doesn't seem to work here
18b2aa6a 105 is_deeply $node->{prereqs}{configure}{requires}, $mb_prereq, 'Add M::B to configure_requires';
23837600
DG
106}
107
bb4e9162
YST
108$dist->clean;
109