ExtUtils::MakeMaker 6.55_02
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / t / metafile_data.t
1 BEGIN {
2     if( $ENV{PERL_CORE} ) {
3         chdir 't' if -d 't';
4         @INC = ('../lib', 'lib');
5     }
6     else {
7         unshift @INC, 't/lib';
8     }
9 }
10
11 use strict;
12 use Test::More tests => 7;
13
14 use Data::Dumper;
15
16 require ExtUtils::MM_Any;
17
18 my $new_mm = sub {
19     return bless { ARGS => {@_}, @_ }, 'ExtUtils::MM_Any';
20 };
21
22 {
23     my $mm = $new_mm->(
24         DISTNAME        => 'Foo-Bar',
25         VERSION         => 1.23,
26         PM              => {
27             "Foo::Bar"          => 'lib/Foo/Bar.pm',
28         },
29     );
30
31     is_deeply [$mm->metafile_data], [
32         name            => 'Foo-Bar',
33         version         => 1.23,
34         abstract        => undef,
35         author          => [],
36         license         => 'unknown',
37         distribution_type       => 'module',
38
39         configure_requires      => {
40             'ExtUtils::MakeMaker'       => 0,
41         },
42         build_requires      => {
43             'ExtUtils::MakeMaker'       => 0,
44         },
45
46         no_index        => {
47             directory           => [qw(t inc)],
48         },
49
50         generated_by => "ExtUtils::MakeMaker version $ExtUtils::MakeMaker::VERSION",
51         'meta-spec'  => {
52             url         => 'http://module-build.sourceforge.net/META-spec-v1.4.html', 
53             version     => 1.4
54         },
55     ];
56
57
58     is_deeply [$mm->metafile_data({}, { no_index => { directory => [qw(foo)] } })], [
59         name            => 'Foo-Bar',
60         version         => 1.23,
61         abstract        => undef,
62         author          => [],
63         license         => 'unknown',
64         distribution_type       => 'module',
65
66         configure_requires      => {
67             'ExtUtils::MakeMaker'       => 0,
68         },
69         build_requires      => {
70             'ExtUtils::MakeMaker'       => 0,
71         },
72
73         no_index        => {
74             directory           => [qw(t inc foo)],
75         },
76
77         generated_by => "ExtUtils::MakeMaker version $ExtUtils::MakeMaker::VERSION",
78         'meta-spec'  => {
79             url         => 'http://module-build.sourceforge.net/META-spec-v1.4.html', 
80             version     => 1.4
81         },
82     ], 'rt.cpan.org 39348';
83 }
84
85
86 {
87     my $mm = $new_mm->(
88         DISTNAME        => 'Foo-Bar',
89         VERSION         => 1.23,
90         AUTHOR          => 'Some Guy',
91         PREREQ_PM       => {
92             Foo                 => 2.34,
93             Bar                 => 4.56,
94         },
95     );
96
97     is_deeply [$mm->metafile_data(
98         {
99             configure_requires => {
100                 Stuff   => 2.34
101             },
102             wobble      => 42
103         },
104         {
105             no_index    => {
106                 package => "Thing"
107             },
108             wibble      => 23
109         },
110     )],
111     [
112         name            => 'Foo-Bar',
113         version         => 1.23,
114         abstract        => undef,
115         author          => ['Some Guy'],
116         license         => 'unknown',
117         distribution_type       => 'script',
118
119         configure_requires      => {
120             Stuff       => 2.34,
121         },
122         build_requires      => {
123             'ExtUtils::MakeMaker'       => 0,
124         },
125
126         requires       => {
127             Foo                 => 2.34,
128             Bar                 => 4.56,
129         },
130
131         no_index        => {
132             directory           => [qw(t inc)],
133             package             => 'Thing',
134         },
135
136         generated_by => "ExtUtils::MakeMaker version $ExtUtils::MakeMaker::VERSION",
137         'meta-spec'  => {
138             url         => 'http://module-build.sourceforge.net/META-spec-v1.4.html', 
139             version     => 1.4
140         },
141
142         wibble  => 23,
143         wobble  => 42,
144     ];
145 }
146
147
148 # Test MIN_PERL_VERSION
149 {
150     my $mm = $new_mm->(
151         DISTNAME        => 'Foo-Bar',
152         VERSION         => 1.23,
153         PM              => {
154             "Foo::Bar"          => 'lib/Foo/Bar.pm',
155         },
156         MIN_PERL_VERSION => 5.006,
157     );
158
159     is_deeply [$mm->metafile_data], [
160         name            => 'Foo-Bar',
161         version         => 1.23,
162         abstract        => undef,
163         author          => [],
164         license         => 'unknown',
165         distribution_type       => 'module',
166
167         configure_requires      => {
168             'ExtUtils::MakeMaker'       => 0,
169         },
170         build_requires      => {
171             'ExtUtils::MakeMaker'       => 0,
172         },
173
174         requires        => {
175             perl        => '5.006',
176         },
177
178         no_index        => {
179             directory           => [qw(t inc)],
180         },
181
182         generated_by => "ExtUtils::MakeMaker version $ExtUtils::MakeMaker::VERSION",
183         'meta-spec'  => {
184             url         => 'http://module-build.sourceforge.net/META-spec-v1.4.html', 
185             version     => 1.4
186         },
187     ];
188 }
189
190
191 # Test MIN_PERL_VERSION
192 {
193     my $mm = $new_mm->(
194         DISTNAME        => 'Foo-Bar',
195         VERSION         => 1.23,
196         PM              => {
197             "Foo::Bar"          => 'lib/Foo/Bar.pm',
198         },
199         MIN_PERL_VERSION => 5.006,
200         PREREQ_PM => {
201             'Foo::Bar'  => 1.23,
202         },
203     );
204
205     is_deeply [$mm->metafile_data], [
206         name            => 'Foo-Bar',
207         version         => 1.23,
208         abstract        => undef,
209         author          => [],
210         license         => 'unknown',
211         distribution_type       => 'module',
212
213         configure_requires      => {
214             'ExtUtils::MakeMaker'       => 0,
215         },
216         build_requires      => {
217             'ExtUtils::MakeMaker'       => 0,
218         },
219
220         requires        => {
221             perl        => '5.006',
222             'Foo::Bar'  => 1.23,
223         },
224
225         no_index        => {
226             directory           => [qw(t inc)],
227         },
228
229         generated_by => "ExtUtils::MakeMaker version $ExtUtils::MakeMaker::VERSION",
230         'meta-spec'  => {
231             url         => 'http://module-build.sourceforge.net/META-spec-v1.4.html', 
232             version     => 1.4
233         },
234     ];
235 }
236
237 # Test CONFIGURE_REQUIRES
238 {
239     my $mm = $new_mm->(
240         DISTNAME        => 'Foo-Bar',
241         VERSION         => 1.23,
242         CONFIGURE_REQUIRES => {
243             "Fake::Module1" => 1.01,
244         },
245         PM              => {
246             "Foo::Bar"          => 'lib/Foo/Bar.pm',
247         },
248     );
249
250     is_deeply [$mm->metafile_data], [
251         name            => 'Foo-Bar',
252         version         => 1.23,
253         abstract        => undef,
254         author          => [],
255         license         => 'unknown',
256         distribution_type       => 'module',
257
258         configure_requires      => {
259             'Fake::Module1'       => 1.01,
260         },
261         build_requires      => {
262             'ExtUtils::MakeMaker'       => 0,
263         },
264
265         no_index        => {
266             directory           => [qw(t inc)],
267         },
268
269         generated_by => "ExtUtils::MakeMaker version $ExtUtils::MakeMaker::VERSION",
270         'meta-spec'  => {
271             url         => 'http://module-build.sourceforge.net/META-spec-v1.4.html', 
272             version     => 1.4
273         },
274     ],'CONFIGURE_REQUIRES';
275 }
276
277 # Test BUILD_REQUIRES
278 {
279     my $mm = $new_mm->(
280         DISTNAME        => 'Foo-Bar',
281         VERSION         => 1.23,
282         BUILD_REQUIRES => {
283             "Fake::Module1" => 1.01,
284         },
285         PM              => {
286             "Foo::Bar"          => 'lib/Foo/Bar.pm',
287         },
288     );
289
290     is_deeply [$mm->metafile_data], [
291         name            => 'Foo-Bar',
292         version         => 1.23,
293         abstract        => undef,
294         author          => [],
295         license         => 'unknown',
296         distribution_type       => 'module',
297
298         configure_requires      => {
299             'ExtUtils::MakeMaker'       => 0,
300         },
301         build_requires      => {
302             'Fake::Module1'       => 1.01,
303         },
304
305         no_index        => {
306             directory           => [qw(t inc)],
307         },
308
309         generated_by => "ExtUtils::MakeMaker version $ExtUtils::MakeMaker::VERSION",
310         'meta-spec'  => {
311             url         => 'http://module-build.sourceforge.net/META-spec-v1.4.html', 
312             version     => 1.4
313         },
314     ],'CONFIGURE_REQUIRES';
315 }