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