1Test::Compile(3) User Contributed Perl Documentation Test::Compile(3)
2
3
4
6 Test::Compile - Check whether Perl files compile correctly.
7
9 use Test::Compile;
10
11 my $test = Test::Compile->new();
12 $test->all_files_ok();
13 $test->done_testing();
14
16 "Test::Compile" lets you check the whether your perl modules and
17 scripts compile properly, results are reported in standard
18 "Test::Simple" fashion.
19
20 The basic usage - as shown above, will locate your perl files and test
21 that they all compile.
22
23 Module authors can (and probably should) include the following in a
24 t/00-compile.t file and have "Test::Compile" automatically find and
25 check all Perl files in a module distribution:
26
27 #!perl
28 use strict;
29 use warnings;
30 use Test::Compile;
31 my $test = Test::Compile->new();
32 $test->all_files_ok();
33 $test->done_testing();
34
36 "new()"
37 The constructor, which actually returns a Test::Compile::Internal
38 object. This gives you access to all the methods provided by
39 "Test::Compile::Internal", including those listed below.
40
41 "all_files_ok(@dirs)"
42 Looks for perl files and tests them all for compilation errors.
43
44 See "all_files_ok(@dirs)" in Test::Compile::Internal for the full
45 documentation.
46
47 "done_testing()"
48 Declares that you are done testing, no more tests will be run after
49 this point.
50
51 "diag(@msgs)"
52 Prints out the given @msgs. Like print, arguments are simply
53 appended together.
54
55 Output will be indented and marked with a # so as not to interfere
56 with test output. A newline will be put on the end if there isn't
57 one already.
58
59 We encourage using this rather than calling print directly.
60
61 "skip($reason)"
62 Skips the current test, reporting the $reason.
63
65 The use of the following functions is deprecated and strongly
66 discouraged.
67
68 They are automatically exported to your namespace, which is no longer
69 considered best practise. At some stage in the future, this will stop
70 and you'll have to import them explicitly.
71
72 Even then, you really should use the object oriented methods as they
73 provide a more consistent interface. For example: "all_pm_files_ok()"
74 calls the "plan()" function - so you can't call multiple test functions
75 in the same test file.
76
77 You should definitely use the object oriented interface described in
78 the "SYNOPSIS" and in Test::Compile::Internal instead of calling these
79 functions.
80
81 "all_pm_files_ok(@files)"
82 This function is deprecated. Please use "all_pm_files_ok(@dirs)"
83 in Test::Compile::Internal instead. It's pretty much the same,
84 except it doesn't call the "plan()" function.
85
86 Checks all the perl module files it can find for compilation
87 errors.
88
89 It uses "all_pm_files(@files)" to find the perl module files.
90
91 It also calls the "plan()" function for you (one test for each
92 module), so you can't have already called "plan()". Unfortunately,
93 this also means you can't use this function with
94 "all_pl_files_ok()". If this is a problem you should really be
95 using the object oriented interface.
96
97 Returns true if all Perl module files are ok, or false if any fail.
98
99 "all_pl_files_ok(@files)"
100 This function is deprecated. Please use "all_pl_files_ok(@dirs)"
101 in Test::Compile::Internal instead. It's pretty much the same,
102 except it doesn't call the "plan()" function.
103
104 Checks all the perl script files it can find for compilation
105 errors.
106
107 It uses "all_pl_files(@files)" to find the perl script files.
108
109 It also calls the "plan()" function for you (one test for each
110 script), so you can't have already called "plan". Unfortunately,
111 this also means you can't use this function with
112 "all_pm_files_ok()". If this is a problem you should really be
113 using the object oriented interface.
114
115 Returns true if all Perl script files are ok, or false if any fail.
116
117 "pm_file_ok($filename, $testname)"
118 This function is deprecated. Please use "all_pm_files_ok(@dirs)"
119 in Test::Compile::Internal instead. It's pretty much the same,
120 except you can't specify a test name, and it can handle more than
121 one file at a time.
122
123 "pm_file_ok()" will okay the test if $filename compiles as a perl
124 module.
125
126 The optional second argument $testname is the name of the test. If
127 it is omitted, "pm_file_ok()" chooses a default test name "Compile
128 test for $filename".
129
130 "pl_file_ok($filename, $testname)"
131 This function is deprecated. Please use "all_pl_files_ok(@dirs)"
132 in Test::Compile::Internal instead. It's pretty much the same,
133 except you can't specify a test name, and it can handle more than
134 one file at a time.
135
136 "pl_file_ok()" will okay the test if $filename compiles as a perl
137 script. You need to give the path to the script relative to this
138 distribution's base directory. So if you put your scripts in a
139 'top-level' directory called script the argument would be
140 "script/filename".
141
142 The optional second argument $testname is the name of the test. If
143 it is omitted, "pl_file_ok()" chooses a default test name "Compile
144 test for $filename".
145
146 "all_pm_files(@dirs)"
147 This function is deprecated. Please use "all_pm_files(@dirs)" in
148 Test::Compile::Internal instead.
149
150 Returns a list of all the perl module files - that is, files ending
151 in .pm - in @dirs and in directories below. If no directories are
152 passed, it defaults to blib if blib exists, or else lib if not.
153 Skips any files in CVS, .svn, or .git directories.
154
155 The order of the files returned is machine-dependent. If you want
156 them sorted, you'll have to sort them yourself.
157
158 "all_pl_files(@dirs)"
159 This function is deprecated. Please use "all_pl_files(@dirs)" in
160 Test::Compile::Internal instead.
161
162 Returns a list of all the perl script files - that is, any files in
163 @dirs that either have a .pl extension, or have no extension and
164 have a perl shebang line.
165
166 If @dirs is undefined, it searches script if script exists, or else
167 bin if bin exists.
168
169 Skips any files in CVS, .svn, or .git directories.
170
171 The order of the files returned is machine-dependent. If you want
172 them sorted, you'll have to sort them yourself.
173
174 "all_files_ok(@dirs)"
175 This function is deprecated. Please use "all_files_ok(@dirs)" in
176 Test::Compile::Internal instead.
177
178 Checks all the perl files it can find for compilation errors.
179
180 If @dirs is defined then it is taken as an array of directories to
181 be searched for perl files, otherwise it searches some default
182 locations - see "all_pm_files(@dirs)" and "all_pl_files(@dirs)".
183
185 Sagar R. Shah "<srshah@cpan.org>", Marcel GrĂ¼nauer,
186 "<marcel@cpan.org>", Evan Giles, "<egiles@cpan.org>"
187
189 Copyright 2007-2019 by the authors.
190
191 This library is free software; you can redistribute it and/or modify it
192 under the same terms as Perl itself.
193
195 Test::Compile::Internal provides the object oriented interface to (and
196 the inner workings for) the Test::Compile functionality.
197
198 Test::Strict provides functions to ensure your perl files compile, with
199 added bonus that it will check you have used strict in all your files.
200 Test::LoadAllModules just handles modules, not script files, but has
201 more fine-grained control.
202
203
204
205perl v5.30.0 2019-10-23 Test::Compile(3)