line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::CPAN::Meta; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
90376
|
use warnings; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
285
|
|
4
|
8
|
|
|
8
|
|
35
|
use strict; |
|
8
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
228
|
|
5
|
|
|
|
|
|
|
|
6
|
8
|
|
|
8
|
|
30
|
use vars qw($VERSION); |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
493
|
|
7
|
|
|
|
|
|
|
$VERSION = '0.24'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Test::CPAN::Meta - Validate your CPAN META.yml files. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
There are two forms this module can be used. |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
The first is a standalone test of your distribution's META.yml file: |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
use Test::More; |
22
|
|
|
|
|
|
|
eval "use Test::CPAN::Meta"; |
23
|
|
|
|
|
|
|
plan skip_all => "Test::CPAN::Meta required for testing META.yml" if $@; |
24
|
|
|
|
|
|
|
meta_yaml_ok(); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Note that you may provide an optional label/comment/message/etc to the |
27
|
|
|
|
|
|
|
function, or one will be created automatically. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
The second form allows you to test other META.yml files, or specify a specific |
30
|
|
|
|
|
|
|
version you wish to test against: |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
use Test::More test => 6; |
33
|
|
|
|
|
|
|
use Test::CPAN::Meta; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# specify a file and specification version |
36
|
|
|
|
|
|
|
meta_spec_ok('META.yml','1.3',$msg); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# specify the specification version to validate the local META.yml |
39
|
|
|
|
|
|
|
meta_spec_ok(undef,'1.3',$msg); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# specify a file, where the specification version is deduced |
42
|
|
|
|
|
|
|
# from the file itself |
43
|
|
|
|
|
|
|
meta_spec_ok('META.yml',undef,$msg); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Note that this form requires you to specify the number of tests you will be |
46
|
|
|
|
|
|
|
running in your test script. Also note that each 'meta_spec_ok' is actually 2 |
47
|
|
|
|
|
|
|
tests under the hood. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 DESCRIPTION |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
This distribution was written to ensure that a META.yml file, provided with a |
52
|
|
|
|
|
|
|
standard distribution uploaded to CPAN, meets the specifications that are |
53
|
|
|
|
|
|
|
slowly being introduced to module uploads, via the use of package makers and |
54
|
|
|
|
|
|
|
installers such as L, L and |
55
|
|
|
|
|
|
|
L. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
See L for further details of the CPAN Meta Specification. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
############################################################################# |
64
|
|
|
|
|
|
|
#Library Modules # |
65
|
|
|
|
|
|
|
############################################################################# |
66
|
|
|
|
|
|
|
|
67
|
8
|
|
|
8
|
|
5213
|
use Parse::CPAN::Meta; |
|
8
|
|
|
|
|
7833
|
|
|
8
|
|
|
|
|
337
|
|
68
|
8
|
|
|
8
|
|
890
|
use Test::Builder; |
|
8
|
|
|
|
|
9348
|
|
|
8
|
|
|
|
|
151
|
|
69
|
8
|
|
|
8
|
|
3534
|
use Test::CPAN::Meta::Version; |
|
8
|
|
|
|
|
22
|
|
|
8
|
|
|
|
|
536
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
my $Test = Test::Builder->new(); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub import { |
76
|
8
|
|
|
8
|
|
105
|
my $self = shift; |
77
|
8
|
|
|
|
|
17
|
my $caller = caller; |
78
|
8
|
|
|
8
|
|
54
|
no strict 'refs'; |
|
8
|
|
|
|
|
7
|
|
|
8
|
|
|
|
|
2275
|
|
79
|
8
|
|
|
|
|
14
|
*{$caller.'::meta_yaml_ok'} = \&meta_yaml_ok; |
|
8
|
|
|
|
|
494
|
|
80
|
8
|
|
|
|
|
14
|
*{$caller.'::meta_spec_ok'} = \&meta_spec_ok; |
|
8
|
|
|
|
|
24
|
|
81
|
|
|
|
|
|
|
|
82
|
8
|
|
|
|
|
36
|
$Test->exported_to($caller); |
83
|
8
|
|
|
|
|
82
|
$Test->plan(@_); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
############################################################################# |
87
|
|
|
|
|
|
|
#Interface Functions # |
88
|
|
|
|
|
|
|
############################################################################# |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 FUNCTIONS |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=over |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=item * meta_yaml_ok([$msg]) |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Basic META.yml wrapper around meta_spec_ok. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Returns a hash reference to the contents of the parsed META.yml |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=cut |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub meta_yaml_ok { |
103
|
1
|
|
|
1
|
1
|
29
|
$Test->plan( tests => 2 ); |
104
|
1
|
|
|
|
|
496
|
return meta_spec_ok(undef,undef,@_); |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=item * meta_spec_ok($file, $version [,$msg]) |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Validates the named file against the given specification version. Both $file |
110
|
|
|
|
|
|
|
and $version can be undefined. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Returns a hash reference to the contents of the given file, after it has been |
113
|
|
|
|
|
|
|
parsed. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=back |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=cut |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub meta_spec_ok { |
120
|
10
|
|
|
10
|
1
|
3033
|
my ($file, $vers, $msg) = @_; |
121
|
10
|
|
100
|
|
|
33
|
$file ||= 'META.yml'; |
122
|
|
|
|
|
|
|
|
123
|
10
|
100
|
|
|
|
25
|
unless($msg) { |
124
|
8
|
|
|
|
|
13
|
$msg = "$file meets the designated specification"; |
125
|
8
|
100
|
|
|
|
38
|
$msg .= " ($vers)" if($vers); |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
10
|
|
|
|
|
14
|
my ($data) = eval { Parse::CPAN::Meta::LoadFile($file) }; |
|
10
|
|
|
|
|
71
|
|
129
|
|
|
|
|
|
|
|
130
|
10
|
50
|
|
|
|
71687
|
if($@) { |
131
|
0
|
|
|
|
|
0
|
$Test->ok(0,"$file contains valid YAML"); |
132
|
0
|
|
|
|
|
0
|
$Test->ok(0,$msg); |
133
|
0
|
|
|
|
|
0
|
$Test->diag(" ERR: $@"); |
134
|
0
|
|
|
|
|
0
|
return; |
135
|
|
|
|
|
|
|
} else { |
136
|
10
|
|
|
|
|
58
|
$Test->ok(1,"$file contains valid YAML"); |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
10
|
|
|
|
|
3372
|
my %hash; |
140
|
10
|
100
|
|
|
|
36
|
$hash{spec} = $vers if($vers); |
141
|
10
|
|
|
|
|
19
|
$hash{data} = $data; |
142
|
|
|
|
|
|
|
|
143
|
10
|
|
|
|
|
76
|
my $spec = Test::CPAN::Meta::Version->new(%hash); |
144
|
10
|
100
|
|
|
|
34
|
if(my $result = $spec->parse()) { |
145
|
2
|
|
|
|
|
6
|
$Test->ok(0,$msg); |
146
|
2
|
|
|
|
|
727
|
$Test->diag(" ERR: $_") for($spec->errors); |
147
|
|
|
|
|
|
|
} else { |
148
|
8
|
|
|
|
|
24
|
$Test->ok(1,$msg); |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
10
|
|
|
|
|
2267
|
return $data; |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
q( "Before software can be reusable it first has to be usable." - Ralph Johnson ); |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
__END__ |