1PROVE(1) User Contributed Perl Documentation PROVE(1)
2
3
4
6 prove - Run tests through a TAP harness.
7
9 prove [options] [files or directories]
10
12 Boolean options:
13
14 -v, --verbose Print all test lines.
15 -l, --lib Add 'lib' to the path for your tests (-Ilib).
16 -b, --blib Add 'blib/lib' and 'blib/arch' to the path for
17 your tests
18 -s, --shuffle Run the tests in random order.
19 -c, --color Colored test output (default).
20 --nocolor Do not color test output.
21 --count Show the X/Y test count when not verbose
22 (default)
23 --nocount Disable the X/Y test count.
24 -D --dry Dry run. Show test that would have run.
25 -f, --failures Show failed tests.
26 -o, --comments Show comments.
27 --ignore-exit Ignore exit status from test scripts.
28 -m, --merge Merge test scripts' STDERR with their STDOUT.
29 -r, --recurse Recursively descend into directories.
30 --reverse Run the tests in reverse order.
31 -q, --quiet Suppress some test output while running tests.
32 -Q, --QUIET Only print summary results.
33 -p, --parse Show full list of TAP parse errors, if any.
34 --directives Only show results with TODO or SKIP directives.
35 --timer Print elapsed time after each test.
36 --trap Trap Ctrl-C and print summary on interrupt.
37 --normalize Normalize TAP output in verbose output
38 -T Enable tainting checks.
39 -t Enable tainting warnings.
40 -W Enable fatal warnings.
41 -w Enable warnings.
42 -h, --help Display this help
43 -?, Display this help
44 -H, --man Longer manpage for prove
45 --norc Don't process default .proverc
46
47 Options that take arguments:
48
49 -I Library paths to include.
50 -P Load plugin (searches App::Prove::Plugin::*.)
51 -M Load a module.
52 -e, --exec Interpreter to run the tests ('' for compiled
53 tests.)
54 --ext Set the extension for tests (default '.t')
55 --harness Define test harness to use. See TAP::Harness.
56 --formatter Result formatter to use. See FORMATTERS.
57 --source Load and/or configure a SourceHandler. See
58 SOURCE HANDLERS.
59 -a, --archive out.tgz Store the resulting TAP in an archive file.
60 -j, --jobs N Run N test jobs in parallel (try 9.)
61 --state=opts Control prove's persistent state.
62 --rc=rcfile Process options from rcfile
63 --rules Rules for parallel vs sequential processing.
64
66 .proverc
67 If ~/.proverc or ./.proverc exist they will be read and any options
68 they contain processed before the command line options. Options in
69 .proverc are specified in the same way as command line options:
70
71 # .proverc
72 --state=hot,fast,save
73 -j9
74
75 Additional option files may be specified with the "--rc" option.
76 Default option file processing is disabled by the "--norc" option.
77
78 Under Windows and VMS the option file is named _proverc rather than
79 .proverc and is sought only in the current directory.
80
81 Reading from "STDIN"
82 If you have a list of tests (or URLs, or anything else you want to
83 test) in a file, you can add them to your tests by using a '-':
84
85 prove - < my_list_of_things_to_test.txt
86
87 See the "README" in the "examples" directory of this distribution.
88
89 Default Test Directory
90 If no files or directories are supplied, "prove" looks for all files
91 matching the pattern "t/*.t".
92
93 Colored Test Output
94 Colored test output is the default, but if output is not to a terminal,
95 color is disabled. You can override this by adding the "--color"
96 switch.
97
98 Color support requires Term::ANSIColor on Unix-like platforms and
99 Win32::Console windows. If the necessary module is not installed
100 colored output will not be available.
101
102 Exit Code
103 If the tests fail "prove" will exit with non-zero status.
104
105 Arguments to Tests
106 It is possible to supply arguments to tests. To do so separate them
107 from prove's own arguments with the arisdottle, '::'. For example
108
109 prove -v t/mytest.t :: --url http://example.com
110
111 would run t/mytest.t with the options '--url http://example.com'. When
112 running multiple tests they will each receive the same arguments.
113
114 "--exec"
115 Normally you can just pass a list of Perl tests and the harness will
116 know how to execute them. However, if your tests are not written in
117 Perl or if you want all tests invoked exactly the same way, use the
118 "-e", or "--exec" switch:
119
120 prove --exec '/usr/bin/ruby -w' t/
121 prove --exec '/usr/bin/perl -Tw -mstrict -Ilib' t/
122 prove --exec '/path/to/my/customer/exec'
123
124 "--merge"
125 If you need to make sure your diagnostics are displayed in the correct
126 order relative to test results you can use the "--merge" option to
127 merge the test scripts' STDERR into their STDOUT.
128
129 This guarantees that STDOUT (where the test results appear) and STDERR
130 (where the diagnostics appear) will stay in sync. The harness will
131 display any diagnostics your tests emit on STDERR.
132
133 Caveat: this is a bit of a kludge. In particular note that if anything
134 that appears on STDERR looks like a test result the test harness will
135 get confused. Use this option only if you understand the consequences
136 and can live with the risk.
137
138 "--trap"
139 The "--trap" option will attempt to trap SIGINT (Ctrl-C) during a test
140 run and display the test summary even if the run is interrupted
141
142 "--state"
143 You can ask "prove" to remember the state of previous test runs and
144 select and/or order the tests to be run based on that saved state.
145
146 The "--state" switch requires an argument which must be a comma
147 separated list of one or more of the following options.
148
149 "last"
150 Run the same tests as the last time the state was saved. This makes
151 it possible, for example, to recreate the ordering of a shuffled
152 test.
153
154 # Run all tests in random order
155 $ prove -b --state=save --shuffle
156
157 # Run them again in the same order
158 $ prove -b --state=last
159
160 "failed"
161 Run only the tests that failed on the last run.
162
163 # Run all tests
164 $ prove -b --state=save
165
166 # Run failures
167 $ prove -b --state=failed
168
169 If you also specify the "save" option newly passing tests will be
170 excluded from subsequent runs.
171
172 # Repeat until no more failures
173 $ prove -b --state=failed,save
174
175 "passed"
176 Run only the passed tests from last time. Useful to make sure that
177 no new problems have been introduced.
178
179 "all"
180 Run all tests in normal order. Multple options may be specified, so
181 to run all tests with the failures from last time first:
182
183 $ prove -b --state=failed,all,save
184
185 "hot"
186 Run the tests that most recently failed first. The last failure
187 time of each test is stored. The "hot" option causes tests to be
188 run in most-recent- failure order.
189
190 $ prove -b --state=hot,save
191
192 Tests that have never failed will not be selected. To run all tests
193 with the most recently failed first use
194
195 $ prove -b --state=hot,all,save
196
197 This combination of options may also be specified thus
198
199 $ prove -b --state=adrian
200
201 "todo"
202 Run any tests with todos.
203
204 "slow"
205 Run the tests in slowest to fastest order. This is useful in
206 conjunction with the "-j" parallel testing switch to ensure that
207 your slowest tests start running first.
208
209 $ prove -b --state=slow -j9
210
211 "fast"
212 Run test tests in fastest to slowest order.
213
214 "new"
215 Run the tests in newest to oldest order based on the modification
216 times of the test scripts.
217
218 "old"
219 Run the tests in oldest to newest order.
220
221 "fresh"
222 Run those test scripts that have been modified since the last test
223 run.
224
225 "save"
226 Save the state on exit. The state is stored in a file called .prove
227 (_prove on Windows and VMS) in the current directory.
228
229 The "--state" switch may be used more than once.
230
231 $ prove -b --state=hot --state=all,save
232
233 --rules
234 The "--rules" option is used to control which tests are run
235 sequentially and which are run in parallel, if the "--jobs" option is
236 specified. The option may be specified multiple times, and the order
237 matters.
238
239 The most practical use is likely to specify that some tests are not
240 "parallel-ready". Since mentioning a file with --rules doens't cause
241 it to selected to run as a test, you can "set and forget" some rules
242 preferences in your .proverc file. Then you'll be able to take maximum
243 advantage of the performance benefits of parallel testing, while some
244 exceptions are still run in parallel.
245
246 --rules examples
247
248 # All tests are allowed to run in parallel, except those starting with "p"
249 --rules='seq=t/p*.t' --rules='par=**'
250
251 # All tests must run in sequence except those starting with "p", which should be run parallel
252 --rules='par=t/p*.t'
253
254 --rules resolution
255
256 · By default, all tests are eligible to be run in parallel.
257 Specifying any of your own rules removes this one.
258
259 · "First match wins". The first rule that matches a test will be the
260 one that applies.
261
262 · Any test which does not match a rule will be run in sequence at the
263 end of the run.
264
265 · The existence of a rule does not imply selecting a test. You must
266 still specify the tests to run.
267
268 · Specifying a rule to allow tests to run in parallel does not make
269 the run in parallel. You still need specify the number of parallel
270 "jobs" in your Harness object.
271
272 --rules Glob-style pattern matching
273
274 We implement our own glob-style pattern matching for --rules. Here are
275 the supported patterns:
276
277 ** is any number of characters, including /, within a pathname
278 * is zero or more characters within a filename/directory name
279 ? is exactly one character within a filename/directory name
280 {foo,bar,baz} is any of foo, bar or baz.
281 \ is an escape character
282
283 More advance specifications for parallel vs sequence run rules
284
285 If you need more advanced management of what runs in parallel vs in
286 sequence, see the associated 'rules' documentation in TAP::Harness and
287 TAP::Parser::Scheduler. If what's possible directly through "prove" is
288 not sufficient, you can write your own harness to access these features
289 directly.
290
291 @INC
292 prove introduces a separation between "options passed to the perl which
293 runs prove" and "options passed to the perl which runs tests"; this
294 distinction is by design. Thus the perl which is running a test starts
295 with the default @INC. Additional library directories can be added via
296 the "PERL5LIB" environment variable, via -Ifoo in "PERL5OPT" or via the
297 "-Ilib" option to prove.
298
299 Taint Mode
300 Normally when a Perl program is run in taint mode the contents of the
301 "PERL5LIB" environment variable do not appear in @INC.
302
303 Because "PERL5LIB" is often used during testing to add build
304 directories to @INC prove passes the names of any directories found in
305 "PERL5LIB" as -I switches. The net effect of this is that "PERL5LIB" is
306 honoured even when prove is run in taint mode.
307
309 You can load a custom TAP::Parser::Formatter:
310
311 prove --formatter MyFormatter
312
314 You can load custom TAP::Parser::SourceHandlers, to change the way the
315 parser interprets particular sources of TAP.
316
317 prove --source MyHandler --source YetAnother t
318
319 If you want to provide config to the source you can use:
320
321 prove --source MyCustom \
322 --source Perl --perl-option 'foo=bar baz' --perl-option avg=0.278 \
323 --source File --file-option extensions=.txt --file-option extensions=.tmp t
324 --source pgTAP --pgtap-option pset=format=html --pgtap-option pset=border=2
325
326 Each "--$source-option" option must specify a key/value pair separated
327 by an "=". If an option can take multiple values, just specify it
328 multiple times, as with the "extensions=" examples above. If the option
329 should be a hash reference, specify the value as a second pair
330 separated by a "=", as in the "pset=" examples above (escape "=" with a
331 backslash).
332
333 All "--sources" are combined into a hash, and passed to "new" in
334 TAP::Harness's "sources" parameter.
335
336 See TAP::Parser::IteratorFactory for more details on how configuration
337 is passed to SourceHandlers.
338
340 Plugins can be loaded using the "-Pplugin" syntax, eg:
341
342 prove -PMyPlugin
343
344 This will search for a module named "App::Prove::Plugin::MyPlugin", or
345 failing that, "MyPlugin". If the plugin can't be found, "prove" will
346 complain & exit.
347
348 You can pass arguments to your plugin by appending "=arg1,arg2,etc" to
349 the plugin name:
350
351 prove -PMyPlugin=fou,du,fafa
352
353 Please check individual plugin documentation for more details.
354
355 Available Plugins
356 For an up-to-date list of plugins available, please check CPAN:
357
358 <http://search.cpan.org/search?query=App%3A%3AProve+Plugin>
359
360 Writing Plugins
361 Please see "PLUGINS" in App::Prove.
362
364 Hey! The above document had some coding errors, which are explained
365 below:
366
367 Around line 291:
368 Unknown directive: =over4
369
370 Around line 293:
371 '=item' outside of any '=over'
372
373
374
375perl v5.16.3 2013-05-02 PROVE(1)