Add ExtUtils::Miniperl to the list of core modules for all versions >= 5.00504
[p5sagit/p5-mst-13.2.git] / lib / Module / Build / t / metadata2.t
CommitLineData
bb4e9162 1#!/usr/bin/perl -w
2
3use strict;
4use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
738349a8 5use MBTest tests => 20;
6
7use_ok 'Module::Build';
8ensure_blib('Module::Build');
bb4e9162 9
7a827510 10my $tmp = MBTest->tmpdir;
bb4e9162 11
bb4e9162 12use Module::Build::ConfigData;
13use DistGen;
14
15
16############################## ACTION distmeta works without a MANIFEST file
17
18SKIP: {
19 skip( 'YAML_support feature is not enabled', 4 )
20 unless Module::Build::ConfigData->feature('YAML_support');
21
22 my $dist = DistGen->new( dir => $tmp, skip_manifest => 1 );
23 $dist->regen;
24
738349a8 25 $dist->chdir_in;
bb4e9162 26
27 ok ! -e 'MANIFEST';
28
29 my $mb = Module::Build->new_from_context;
30
31 my $out;
32 $out = eval { stderr_of(sub{$mb->dispatch('distmeta')}) };
33 is $@, '';
34
35 like $out, qr/Nothing to enter for 'provides'/;
36
37 ok -e 'META.yml';
38
bb4e9162 39 $dist->remove;
40}
41
42
43############################## Check generation of README file
44
45# TODO: We need to test faking the absence of Pod::Readme when present
46# so Pod::Text will be used. Also fake the absence of both to
47# test that we fail gracefully.
48
49my $provides; # Used a bunch of times below
50
51my $pod_text = <<'---';
52=pod
53
54=head1 NAME
55
56Simple - A simple module
57
58=head1 AUTHOR
59
60Simple Simon <simon@simple.sim>
61
62=cut
63---
64
65my $dist = DistGen->new( dir => $tmp );
66
7a827510 67$dist->change_build_pl
68({
69 module_name => $dist->name,
bb4e9162 70 dist_version => '3.14159265',
71 license => 'perl',
72 create_readme => 1,
7a827510 73});
bb4e9162 74$dist->regen;
75
738349a8 76$dist->chdir_in;
bb4e9162 77
78
79# .pm File with pod
80#
81
82$dist->change_file( 'lib/Simple.pm', <<'---' . $pod_text);
83package Simple;
84$VERSION = '1.23';
85---
86$dist->regen( clean => 1 );
87ok( -e "lib/Simple.pm", "Creating Simple.pm" );
88my $mb = Module::Build->new_from_context;
89$mb->do_create_readme;
90like( slurp("README"), qr/NAME/,
91 "Generating README from .pm");
92is( $mb->dist_author->[0], 'Simple Simon <simon@simple.sim>',
93 "Extracting AUTHOR from .pm");
94is( $mb->dist_abstract, "A simple module",
95 "Extracting abstract from .pm");
96
97# .pm File with pod in separate file
98#
99
100$dist->change_file( 'lib/Simple.pm', <<'---');
101package Simple;
102$VERSION = '1.23';
103---
104$dist->change_file( 'lib/Simple.pod', $pod_text );
105$dist->regen( clean => 1 );
106
107ok( -e "lib/Simple.pm", "Creating Simple.pm" );
108ok( -e "lib/Simple.pod", "Creating Simple.pod" );
109$mb = Module::Build->new_from_context;
110$mb->do_create_readme;
111like( slurp("README"), qr/NAME/, "Generating README from .pod");
112is( $mb->dist_author->[0], 'Simple Simon <simon@simple.sim>',
113 "Extracting AUTHOR from .pod");
114is( $mb->dist_abstract, "A simple module",
115 "Extracting abstract from .pod");
116
117# .pm File with pod and separate pod file
118#
119
120$dist->change_file( 'lib/Simple.pm', <<'---' );
121package Simple;
122$VERSION = '1.23';
123
124=pod
125
126=head1 DONT USE THIS FILE FOR POD
127
128=cut
129---
130$dist->change_file( 'lib/Simple.pod', $pod_text );
131$dist->regen( clean => 1 );
132ok( -e "lib/Simple.pm", "Creating Simple.pm" );
133ok( -e "lib/Simple.pod", "Creating Simple.pod" );
134$mb = Module::Build->new_from_context;
135$mb->do_create_readme;
136like( slurp("README"), qr/NAME/, "Generating README from .pod over .pm");
137is( $mb->dist_author->[0], 'Simple Simon <simon@simple.sim>',
138 "Extracting AUTHOR from .pod over .pm");
139is( $mb->dist_abstract, "A simple module",
140 "Extracting abstract from .pod over .pm");
141
142
143############################################################
144# cleanup
bb4e9162 145$dist->remove;