9b789f04c8796efe123ae6ca35bfb22a7b245b31
[perl.git] / lib / Parse / CPAN / Meta / t / 11_meta_yml.t
1 #!/usr/bin/perl
2
3 # Testing of common META.yml examples
4
5 BEGIN {
6         if( $ENV{PERL_CORE} ) {
7                 chdir 't';
8                 @INC = ('../lib', 'lib');
9         }
10         else {
11                 unshift @INC, 't/lib/';
12         }
13 }
14
15 use strict;
16 BEGIN {
17         $|  = 1;
18         $^W = 1;
19 }
20
21 use File::Spec::Functions ':ALL';
22 use Parse::CPAN::Meta::Test;
23 use Test::More tests(8, 2);
24
25
26
27
28
29 #####################################################################
30 # Testing YAML::Tiny's META.yml file
31
32 yaml_ok(
33         <<'END_YAML',
34 abstract: Read/Write YAML files with as little code as possible
35 author: 'Adam Kennedy <cpan@ali.as>'
36 build_requires:
37   File::Spec: 0.80
38   Test::More: 0.47
39 distribution_type: module
40 generated_by: Module::Install version 0.63
41 license: perl
42 name: YAML-Tiny
43 no_index:
44   directory:
45     - inc
46     - t
47 requires:
48   perl: 5.005
49 version: 0.03
50 END_YAML
51         [ {
52                 abstract          => 'Read/Write YAML files with as little code as possible',
53                 author            => 'Adam Kennedy <cpan@ali.as>',
54                 build_requires    => {
55                         'File::Spec' => '0.80',
56                         'Test::More' => '0.47',
57                 },
58                 distribution_type => 'module',
59                 generated_by      => 'Module::Install version 0.63',
60                 license           => 'perl',
61                 name              => 'YAML-Tiny',
62                 no_index          => {
63                         directory    => [ qw{inc t} ],
64                 },
65                 requires          => {
66                         perl         => '5.005',
67                 },
68                 version           => '0.03',
69         } ],
70         'YAML::Tiny',
71 );
72
73
74
75
76
77
78 #####################################################################
79 # Testing a META.yml from a commercial project that crashed
80
81 yaml_ok(
82         <<'END_YAML',
83 # http://module-build.sourceforge.net/META-spec.html
84 #XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
85 name:         ITS-SIN-FIDS-Content-XML
86 version:      0.01
87 version_from: lib/ITS/SIN/FIDS/Content/XML.pm
88 installdirs:  site
89 requires:
90     Test::More:                    0.45
91     XML::Simple:                   2
92
93 distribution_type: module
94 generated_by: ExtUtils::MakeMaker version 6.30
95 END_YAML
96         [ {
97                 name              => 'ITS-SIN-FIDS-Content-XML',
98                 version           => 0.01,
99                 version_from      => 'lib/ITS/SIN/FIDS/Content/XML.pm',
100                 installdirs       => 'site',
101                 requires          => {
102                         'Test::More'  => 0.45,
103                         'XML::Simple' => 2,
104                         },
105                 distribution_type => 'module',
106                 generated_by      => 'ExtUtils::MakeMaker version 6.30',
107         } ],
108         'YAML::Tiny',
109 );
110
111
112
113
114
115
116 #####################################################################
117 # Testing various failing META.yml files from CPAN
118
119 yaml_ok(
120         <<'END_YAML',
121 ---
122 abstract: Mii in Nintendo Wii data parser and builder
123 author: Toru Yamaguchi <zigorou@cpan.org>
124 distribution_type: module
125 generated_by: Module::Install version 0.65
126 license: perl
127 meta-spec:
128   url: http://module-build.sourceforge.net/META-spec-v1.3.html
129   version: 1.3
130 name: Games-Nintendo-Wii-Mii
131 no_index:
132   directory:
133     - inc
134     - t
135 requires:
136   Carp: 1.03
137   Class::Accessor::Fast: 0.3
138   File::Slurp: 9999.12
139   IO::File: 1.1
140   Readonly: 0
141   Tie::IxHash: 1.21
142   URI: 1.35
143   XML::LibXML: 1.62
144 version: 0.02
145 END_YAML
146         [ {
147                 abstract => 'Mii in Nintendo Wii data parser and builder',
148                 author   => 'Toru Yamaguchi <zigorou@cpan.org>',
149                 distribution_type => 'module',
150                 generated_by => 'Module::Install version 0.65',
151                 license => 'perl',
152                 'meta-spec' => {
153                         url => 'http://module-build.sourceforge.net/META-spec-v1.3.html',
154                         version => '1.3',
155                 },
156                 name => 'Games-Nintendo-Wii-Mii',
157                 no_index => {
158                         directory => [ qw{ inc t } ],
159                 },
160                 requires => {
161                         'Carp' => '1.03',
162                         'Class::Accessor::Fast' => '0.3',
163                         'File::Slurp' => '9999.12',
164                         'IO::File'    => '1.1',
165                         'Readonly'    => '0',
166                         'Tie::IxHash' => '1.21',
167                         'URI'         => '1.35',
168                         'XML::LibXML' => '1.62',
169                 },
170                 version => '0.02',
171         } ],
172         'Games-Nintendo-Wii-Mii',
173 );
174
175 yaml_ok(
176         <<'END_YAML',
177 # http://module-build.sourceforge.net/META-spec.html
178 #XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
179 name:         Acme-Time-Baby
180 version:      2.106
181 version_from: Baby.pm
182 installdirs:  site
183 requires:
184     warnings:
185
186 distribution_type: module
187 generated_by: ExtUtils::MakeMaker version 6.17
188 END_YAML
189         [ {
190                 name => 'Acme-Time-Baby',
191                 version => '2.106',
192                 version_from => 'Baby.pm',
193                 installdirs => 'site',
194                 requires => {
195                         warnings => undef,
196                 },
197                 distribution_type => 'module',
198                 generated_by => 'ExtUtils::MakeMaker version 6.17',
199         } ],
200         'Acme-Time-Baby',
201 );
202
203
204
205
206
207 #####################################################################
208 # File with a YAML header
209
210 yaml_ok(
211         <<'END_YAML',
212 --- %YAML:1.0
213 name:     Data-Swap
214 version:  0.05
215 license:  perl
216 distribution_type: module
217 requires:
218    perl:  5.6.0
219 dynamic_config: 0
220 END_YAML
221         [ {
222                 name => 'Data-Swap',
223                 version => '0.05',
224                 license => 'perl',
225                 distribution_type => 'module',
226                 requires => {
227                         perl => '5.6.0',
228                 },
229                 dynamic_config => '0',
230         } ],
231         'Data-Swap',
232 );
233
234 yaml_ok(
235         <<'END_YAML',
236 --- #YAML:1.0
237 name:     Data-Swap
238 version:  0.05
239 license:  perl
240 distribution_type: module
241 requires:
242    perl:  5.6.0
243 dynamic_config: 0
244 END_YAML
245         [ {
246                 name => 'Data-Swap',
247                 version => '0.05',
248                 license => 'perl',
249                 distribution_type => 'module',
250                 requires => {
251                         perl => '5.6.0',
252                 },
253                 dynamic_config => '0',
254         } ],
255         'Data-Swap',
256 );
257
258
259
260
261
262 #####################################################################
263 # Various files that fail for unknown reasons
264
265 SCOPE: {
266         my $content = load_ok(
267                 'Template-Provider-Unicode-Japanese.yml',
268                 catfile( test_data_directory(), 'Template-Provider-Unicode-Japanese.yml' ),
269                 100
270         );
271         yaml_ok(
272                 $content,
273                 [ {
274                         abstract => 'Decode all templates by Unicode::Japanese',
275                         author   => 'Hironori Yoshida C<< <yoshida@cpan.org> >>',
276                         distribution_type => 'module',
277                         generated_by => 'Module::Install version 0.65',
278                         license => 'perl',
279                         'meta-spec' => {
280                                 url => 'http://module-build.sourceforge.net/META-spec-v1.3.html',
281                                 version => '1.3',
282                         },
283                         name => 'Template-Provider-Unicode-Japanese',
284                         no_index => {
285                                 directory => [ qw{ inc t } ],
286                         },
287                         requires => {
288                                 'Template::Config' => 0,
289                                 'Unicode::Japanese' => 0,
290                                 perl => '5.6.0',
291                                 version => '0',
292                         },
293                         version => '1.2.1',
294                 } ],
295                 'Template-Provider-Unicode-Japanese',
296         );
297 }
298
299 SCOPE: {
300         my $content = load_ok(
301                 'HTML-WebDAO.yml',
302                 catfile( test_data_directory(), 'HTML-WebDAO.yml' ),
303                 100
304         );
305         yaml_ok(
306                 $content,
307                 [ {
308                         abstract => 'Perl extension for create complex web application',
309                         author   => [
310                                 'Zahatski Aliaksandr, E<lt>zagap@users.sourceforge.netE<gt>',
311                         ],
312                         license  => 'perl',
313                         name     => 'HTML-WebDAO',
314                         version  => '0.04',
315                 } ],
316                 'HTML-WebDAO',
317         );
318 }