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