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