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

AUTHORS

178       Sagar R. Shah "<srshah@cpan.org>", Marcel GrĂ¼nauer,
179       "<marcel@cpan.org>", Evan Giles, "<egiles@cpan.org>"
180
182       Copyright 2007-2023 by the authors.
183
184       This library is free software; you can redistribute it and/or modify it
185       under the same terms as Perl itself.
186

SEE ALSO

188       Test::Compile::Internal provides the object oriented interface to (and
189       the inner workings for) the Test::Compile functionality.
190
191       Test::Strict provides functions to ensure your perl files compile, with
192       the added bonus that it will check you have used strict in all your
193       files.
194
195       Test::LoadAllModules just handles modules, not script files, but has
196       more fine-grained control.
197
198
199
200perl v5.38.0                      2023-07-21                  Test::Compile(3)
Impressum