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
1 #!/usr/bin/perl -w
2
3 use strict;
4 use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
5 use MBTest tests => 20;
6
7 use_ok 'Module::Build';
8 ensure_blib('Module::Build');
9
10 my $tmp = MBTest->tmpdir;
11
12 use Module::Build::ConfigData;
13 use DistGen;
14
15
16 ############################## ACTION distmeta works without a MANIFEST file
17
18 SKIP: {
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
25   $dist->chdir_in;
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
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
49 my $provides; # Used a bunch of times below
50
51 my $pod_text = <<'---'; 
52 =pod
53
54 =head1 NAME
55
56 Simple - A simple module 
57
58 =head1 AUTHOR
59
60 Simple Simon <simon@simple.sim>
61
62 =cut
63 ---
64
65 my $dist = DistGen->new( dir => $tmp );
66
67 $dist->change_build_pl
68 ({
69     module_name         => $dist->name,
70     dist_version        => '3.14159265',
71     license             => 'perl',
72     create_readme       => 1,
73 });
74 $dist->regen;
75
76 $dist->chdir_in;
77
78
79 # .pm File with pod
80 #
81
82 $dist->change_file( 'lib/Simple.pm', <<'---' . $pod_text);
83 package Simple;
84 $VERSION = '1.23';
85 ---
86 $dist->regen( clean => 1 );
87 ok( -e "lib/Simple.pm", "Creating Simple.pm" );
88 my $mb = Module::Build->new_from_context;
89 $mb->do_create_readme;
90 like( slurp("README"), qr/NAME/, 
91     "Generating README from .pm");
92 is( $mb->dist_author->[0], 'Simple Simon <simon@simple.sim>', 
93     "Extracting AUTHOR from .pm");
94 is( $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', <<'---');
101 package Simple;
102 $VERSION = '1.23';
103 ---
104 $dist->change_file( 'lib/Simple.pod', $pod_text );
105 $dist->regen( clean => 1 );
106
107 ok( -e "lib/Simple.pm", "Creating Simple.pm" );
108 ok( -e "lib/Simple.pod", "Creating Simple.pod" );
109 $mb = Module::Build->new_from_context;
110 $mb->do_create_readme;
111 like( slurp("README"), qr/NAME/, "Generating README from .pod");
112 is( $mb->dist_author->[0], 'Simple Simon <simon@simple.sim>', 
113     "Extracting AUTHOR from .pod");
114 is( $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', <<'---' );
121 package 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 );
132 ok( -e "lib/Simple.pm", "Creating Simple.pm" );
133 ok( -e "lib/Simple.pod", "Creating Simple.pod" );
134 $mb = Module::Build->new_from_context;
135 $mb->do_create_readme;
136 like( slurp("README"), qr/NAME/, "Generating README from .pod over .pm");
137 is( $mb->dist_author->[0], 'Simple Simon <simon@simple.sim>',
138     "Extracting AUTHOR from .pod over .pm");
139 is( $mb->dist_abstract, "A simple module",
140     "Extracting abstract from .pod over .pm");
141
142
143 ############################################################
144 # cleanup
145 $dist->remove;