1Test::Compile(3)      User Contributed Perl Documentation     Test::Compile(3)
2
3
4

NAME

6       Test::Compile - Assert that your Perl files compile OK.
7

SYNOPSIS

9           use Test::Compile qw();
10
11           my $test = Test::Compile->new();
12           $test->all_files_ok();
13           $test->done_testing();
14

DESCRIPTION

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 qw();
31
32           my $test = Test::Compile->new();
33           $test->all_files_ok();
34           $test->done_testing();
35

METHODS

37       "new()"
38           The constructor, which actually returns a Test::Compile::Internal
39           object.  This gives you access to all the methods provided by
40           "Test::Compile::Internal", including those listed below.
41
42       "all_files_ok(@dirs)"
43           Looks for perl files and tests them all for compilation errors.
44
45           See "all_files_ok(@dirs)" in Test::Compile::Internal for the full
46           documentation.
47
48       "done_testing()"
49           Declares that you are done testing, no more tests will be run after
50           this point.
51
52       "diag(@msgs)"
53           Prints out the given @msgs. Like print, arguments are simply
54           appended together.
55
56           Output will be indented and marked with a # so as not to interfere
57           with test output. A newline will be put on the end if there isn't
58           one already.
59
60           We encourage using this rather than calling print directly.
61
62       "skip($reason)"
63           Skips the current test, reporting the $reason.
64

FUNCTIONS

66       The use of the following functions is deprecated and strongly
67       discouraged.
68
69       They are automatically exported to your namespace,  which is no longer
70       considered best practise.  At some stage in the future, this will stop
71       and you'll have to import them explicitly.
72
73       Even then, you really should use the object oriented methods as they
74       provide a more consistent interface.  For example: "all_pm_files_ok()"
75       calls the "plan()" function - so you can't call multiple test functions
76       in the same test file.
77
78       You should definitely use the object oriented interface described in
79       the "SYNOPSIS" and in Test::Compile::Internal instead of calling these
80       functions.
81
82       "all_pm_files_ok(@files)"
83           This function is deprecated.  Please use "all_pm_files_ok(@dirs)"
84           in Test::Compile::Internal instead.  It's pretty much the same,
85           except it doesn't call the "plan()" function.
86
87           Checks all the perl module files it can find for compilation
88           errors.
89
90           It uses "all_pm_files(@files)" to find the perl module files.
91
92           It also calls the "plan()" function for you (one test for each
93           module), so you can't have already called "plan()". Unfortunately,
94           this also means you can't use this function with
95           "all_pl_files_ok()".  If this is a problem you should really be
96           using the object oriented interface.
97
98           Returns true if all Perl module files are ok, or false if any fail.
99
100       "all_pl_files_ok(@files)"
101           This function is deprecated.  Please use "all_pl_files_ok(@dirs)"
102           in Test::Compile::Internal instead.  It's pretty much the same,
103           except it doesn't call the "plan()" function.
104
105           Checks all the perl script files it can find for compilation
106           errors.
107
108           It uses "all_pl_files(@files)" to find the perl script files.
109
110           It also calls the "plan()" function for you (one test for each
111           script), so you can't have already called "plan". Unfortunately,
112           this also means you can't use this function with
113           "all_pm_files_ok()".  If this is a problem you should really be
114           using the object oriented interface.
115
116           Returns true if all Perl script files are ok, or false if any fail.
117
118       "pm_file_ok($filename, $testname)"
119           This function is deprecated.  Please use "all_pm_files_ok(@dirs)"
120           in Test::Compile::Internal instead.  It's pretty much the same,
121           except you can't specify a test name, and it can handle more than
122           one file at a time.
123
124           "pm_file_ok()" will okay the test if $filename compiles as a perl
125           module.
126
127           The optional second argument $testname is the name of the test. If
128           it is omitted, "pm_file_ok()" chooses a default test name "Compile
129           test for $filename".
130
131       "pl_file_ok($filename, $testname)"
132           This function is deprecated.  Please use "all_pl_files_ok(@dirs)"
133           in Test::Compile::Internal instead.  It's pretty much the same,
134           except you can't specify a test name, and it can handle more than
135           one file at a time.
136
137           "pl_file_ok()" will okay the test if $filename compiles as a perl
138           script. You need to give the path to the script relative to this
139           distribution's base directory. So if you put your scripts in a
140           'top-level' directory called script the argument would be
141           "script/filename".
142
143           The optional second argument $testname is the name of the test. If
144           it is omitted, "pl_file_ok()" chooses a default test name "Compile
145           test for $filename".
146
147       "all_pm_files(@dirs)"
148           This function is deprecated.  Please use "all_pm_files(@dirs)" in
149           Test::Compile::Internal instead.
150
151           Returns a list of all the perl module files - that is, files ending
152           in .pm - in @dirs and in directories below. If no directories are
153           passed, it defaults to blib if blib exists, or else lib if not.
154           Skips any files in CVS, .svn, or .git directories.
155
156           The order of the files returned is machine-dependent. If you want
157           them sorted, you'll have to sort them yourself.
158
159       "all_pl_files(@dirs)"
160           This function is deprecated.  Please use "all_pl_files(@dirs)" in
161           Test::Compile::Internal instead.
162
163           Returns a list of all the perl script files - that is, any files in
164           @dirs that either have a .pl extension, or have no extension and
165           have a perl shebang line.
166
167           If @dirs is undefined, it searches script if script exists, or else
168           bin if bin exists.
169
170           Skips any files in CVS, .svn, or .git directories.
171
172           The order of the files returned is machine-dependent. If you want
173           them sorted, you'll have to sort them yourself.
174
175       "all_files_ok(@dirs)"
176           This function is deprecated.  Please use "all_files_ok(@dirs)" in
177           Test::Compile::Internal instead.
178
179           Checks all the perl files it can find for compilation errors.
180
181           If @dirs is defined then it is taken as an array of directories to
182           be searched for perl files, otherwise it searches some default
183           locations - see "all_pm_files(@dirs)" and "all_pl_files(@dirs)".
184

AUTHORS

186       Sagar R. Shah "<srshah@cpan.org>", Marcel GrĂ¼nauer,
187       "<marcel@cpan.org>", Evan Giles, "<egiles@cpan.org>"
188
190       Copyright 2007-2021 by the authors.
191
192       This library is free software; you can redistribute it and/or modify it
193       under the same terms as Perl itself.
194

SEE ALSO

196       Test::Compile::Internal provides the object oriented interface to (and
197       the inner workings for) the Test::Compile functionality.
198
199       Test::Strict provides functions to ensure your perl files compile, with
200       added bonus that it will check you have used strict in all your files.
201       Test::LoadAllModules just handles modules, not script files, but has
202       more fine-grained control.
203
204
205
206perl v5.34.1                      2022-06-06                  Test::Compile(3)
Impressum