| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Test::Compile; |
|
2
|
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
349809
|
use warnings; |
|
|
8
|
|
|
|
|
105
|
|
|
|
8
|
|
|
|
|
267
|
|
|
4
|
8
|
|
|
8
|
|
42
|
use strict; |
|
|
8
|
|
|
|
|
15
|
|
|
|
8
|
|
|
|
|
161
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
8
|
|
|
8
|
|
3702
|
use version; our $VERSION = version->declare("v3.3.1"); |
|
|
8
|
|
|
|
|
16790
|
|
|
|
8
|
|
|
|
|
44
|
|
|
7
|
8
|
|
|
8
|
|
4581
|
use parent 'Exporter'; |
|
|
8
|
|
|
|
|
2155
|
|
|
|
8
|
|
|
|
|
53
|
|
|
8
|
8
|
|
|
8
|
|
4223
|
use Test::Compile::Internal; |
|
|
8
|
|
|
|
|
23
|
|
|
|
8
|
|
|
|
|
3958
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my $Test = Test::Compile::Internal->new(); |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Test::Compile - Assert that your Perl files compile OK. |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
use Test::Compile qw(); |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $test = Test::Compile->new(); |
|
21
|
|
|
|
|
|
|
$test->all_files_ok(); |
|
22
|
|
|
|
|
|
|
$test->done_testing(); |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
C lets you check the whether your perl modules and scripts |
|
27
|
|
|
|
|
|
|
compile properly, results are reported in standard C fashion. |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
The basic usage - as shown above, will locate your perl files and test that they |
|
30
|
|
|
|
|
|
|
all compile. |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Module authors can (and probably should) include the following in a F |
|
33
|
|
|
|
|
|
|
file and have C automatically find and check all Perl files |
|
34
|
|
|
|
|
|
|
in a module distribution: |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
#!perl |
|
37
|
|
|
|
|
|
|
use strict; |
|
38
|
|
|
|
|
|
|
use warnings; |
|
39
|
|
|
|
|
|
|
use Test::Compile qw(); |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my $test = Test::Compile->new(); |
|
42
|
|
|
|
|
|
|
$test->all_files_ok(); |
|
43
|
|
|
|
|
|
|
$test->done_testing(); |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=cut |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
our @EXPORT = qw( |
|
48
|
|
|
|
|
|
|
pm_file_ok |
|
49
|
|
|
|
|
|
|
pl_file_ok |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
all_pm_files_ok |
|
52
|
|
|
|
|
|
|
all_pl_files_ok |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
all_pm_files |
|
55
|
|
|
|
|
|
|
all_pl_files |
|
56
|
|
|
|
|
|
|
); |
|
57
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
|
58
|
|
|
|
|
|
|
pm_file_ok |
|
59
|
|
|
|
|
|
|
pl_file_ok |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
all_files_ok |
|
62
|
|
|
|
|
|
|
all_pm_files_ok |
|
63
|
|
|
|
|
|
|
all_pl_files_ok |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
all_pm_files |
|
66
|
|
|
|
|
|
|
all_pl_files |
|
67
|
|
|
|
|
|
|
); |
|
68
|
|
|
|
|
|
|
our %EXPORT_TAGS = ('all' => \@EXPORT_OK); |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 METHODS |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=over 4 |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=item C |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
The constructor, which actually returns a |
|
77
|
|
|
|
|
|
|
L object. This gives you access to all the methods provided by |
|
78
|
|
|
|
|
|
|
C, including those listed below. |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub new { |
|
83
|
1
|
|
|
1
|
1
|
87
|
my $class = shift; |
|
84
|
1
|
|
|
|
|
8
|
return Test::Compile::Internal->new(@_); |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=item C |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Looks for perl files and tests them all for compilation errors. |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
See L for the full documentation. |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=item C |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Declares that you are done testing, no more tests will be run after this point. |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=item C |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Prints out the given C<@msgs>. Like print, arguments are simply appended |
|
100
|
|
|
|
|
|
|
together. |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Output will be indented and marked with a # so as not to interfere with |
|
103
|
|
|
|
|
|
|
test output. A newline will be put on the end if there isn't one already. |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
We encourage using this rather than calling print directly. |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=item C |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Skips the current test, reporting the C<$reason>. |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=back |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 FUNCTIONS |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
The use of the following functions is deprecated and strongly discouraged. |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Instead, you should use the object oriented interface described in the L |
|
118
|
|
|
|
|
|
|
and in L. |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
They are automatically exported to your namespace, which is |
|
121
|
|
|
|
|
|
|
no longer considered best practise. At some stage in the future, this will |
|
122
|
|
|
|
|
|
|
stop and you'll have to import them explicitly to keep using them. |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
The object oriented methods also provide a more consistent interface. |
|
125
|
|
|
|
|
|
|
For example: C calls the C function - so you can't call |
|
126
|
|
|
|
|
|
|
multiple test functions in the same test file. |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=over 4 |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=item C |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
B. Please use |
|
133
|
|
|
|
|
|
|
L instead. It's pretty much the |
|
134
|
|
|
|
|
|
|
same, except it doesn't call the C function. |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Checks all the perl module files it can find for compilation errors. |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
It uses C to find the perl module files. |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
It also calls the C function for you (one test for each module), so |
|
141
|
|
|
|
|
|
|
you can't have already called C. Unfortunately, this also means |
|
142
|
|
|
|
|
|
|
you can't use this function with C. If this is a problem |
|
143
|
|
|
|
|
|
|
you should really be using the object oriented interface. |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Returns true if all Perl module files are ok, or false if any fail. |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=cut |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub all_pm_files_ok { |
|
150
|
1
|
50
|
|
1
|
1
|
80
|
my @files = @_ ? @_ : all_pm_files(); |
|
151
|
1
|
|
|
|
|
5
|
$Test->plan(tests => scalar @files); |
|
152
|
1
|
|
|
|
|
1202
|
return $Test->all_pm_files_ok(@files); |
|
153
|
|
|
|
|
|
|
} |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=item C |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
B. Please use |
|
158
|
|
|
|
|
|
|
L instead. It's pretty much the |
|
159
|
|
|
|
|
|
|
same, except it doesn't call the C function. |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Checks all the perl script files it can find for compilation errors. |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
It uses C to find the perl script files. |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
It also calls the C function for you (one test for each script), so |
|
166
|
|
|
|
|
|
|
you can't have already called C. Unfortunately, this also means |
|
167
|
|
|
|
|
|
|
you can't use this function with C. If this is a problem |
|
168
|
|
|
|
|
|
|
you should really be using the object oriented interface. |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Returns true if all Perl script files are ok, or false if any fail. |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=cut |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
sub all_pl_files_ok { |
|
175
|
1
|
50
|
|
1
|
1
|
106
|
my @files = @_ ? @_ : all_pl_files(); |
|
176
|
1
|
50
|
|
|
|
5
|
$Test->skip_all("no pl files found") unless @files; |
|
177
|
1
|
|
|
|
|
7
|
$Test->plan(tests => scalar @files); |
|
178
|
1
|
|
|
|
|
1304
|
$Test->all_pl_files_ok(@files); |
|
179
|
|
|
|
|
|
|
} |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=item C |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
B. Please use |
|
184
|
|
|
|
|
|
|
L instead. It's pretty much the |
|
185
|
|
|
|
|
|
|
same, except it won't allow you to specify a test name, and it can handle more than |
|
186
|
|
|
|
|
|
|
one file at a time. |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
C will okay the test if $filename compiles as a perl module. |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
The optional second argument C<$testname> is the name of the test. If it is |
|
191
|
|
|
|
|
|
|
omitted, C chooses a default test name C
|
|
192
|
|
|
|
|
|
|
$filename>. |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=cut |
|
195
|
|
|
|
|
|
|
sub pm_file_ok { |
|
196
|
2
|
|
|
2
|
1
|
40
|
my ($file, $name) = @_; |
|
197
|
|
|
|
|
|
|
|
|
198
|
2
|
|
66
|
|
|
32
|
$name ||= "Compile test for $file"; |
|
199
|
|
|
|
|
|
|
|
|
200
|
2
|
|
|
|
|
10
|
my $ok = $Test->pm_file_compiles($file); |
|
201
|
|
|
|
|
|
|
|
|
202
|
2
|
|
|
|
|
42
|
$Test->ok($ok, $name); |
|
203
|
2
|
50
|
|
|
|
2037
|
$Test->diag("$file does not compile") unless $ok; |
|
204
|
2
|
|
|
|
|
230
|
return $ok; |
|
205
|
|
|
|
|
|
|
} |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=item C |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
B. Please use |
|
210
|
|
|
|
|
|
|
L instead. It's pretty much the |
|
211
|
|
|
|
|
|
|
same, except you can't specify a test name, and it can handle more than one file at a |
|
212
|
|
|
|
|
|
|
time. |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
C will okay the test if $filename compiles as a perl script. You |
|
215
|
|
|
|
|
|
|
need to give the path to the script relative to this distribution's base |
|
216
|
|
|
|
|
|
|
directory. So if you put your scripts in a 'top-level' directory called script |
|
217
|
|
|
|
|
|
|
the argument would be C |