Codex

PROVE

Section: Perl Programmers Reference Guide (1)

Updated: 2016-01-15

Index?action=index Return to Main Contents


NAME

prove - Run tests through a TAP harness.

USAGE

OPTIONS

Boolean options:

Options that take arguments:

NOTES

.proverc

If ~/.proverc or ./.proverc exist they will be read and any options they contain processed before the command line options. Options in .proverc are specified in the same way as command line options:

Additional option files may be specified with the option. Default option file processing is disabled by the option.

Under Windows and VMS the option file is named _proverc rather than .proverc and is sought only in the current directory.

Reading from STDIN

If you have a list of tests (or URLs, or anything else you want to test) in a file, you can add them to your tests by using a '-':

See the in the directory of this distribution.

Default Test Directory

If no files or directories are supplied, looks for all files matching the pattern .

Colored Test Output

Colored test output using TAP::Formatter::Color is the default, but if output is not to a terminal, color is disabled. You can override this by adding the switch.

Color support requires Term::ANSIColor on Unix-like platforms and Win32::Console on windows. If the necessary module is not installed colored output will not be available.

Exit Code

If the tests fail will exit with non-zero status.

Arguments to Tests

It is possible to supply arguments to tests. To do so separate them from prove's own arguments with the arisdottle, '::'. For example

prove -v t/mytest.t :: --url http://example.com

@]

would run t/mytest.t with the options '--url http://example.com'. When running multiple tests they will each receive the same arguments.

--exec

Normally you can just pass a list of Perl tests and the harness will know how to execute them. However, if your tests are not written in Perl or if you want all tests invoked exactly the same way, use the , or switch:

--merge

If you need to make sure your diagnostics are displayed in the correct order relative to test results you can use the option to merge the test scripts' STDERR into their STDOUT.

This guarantees that STDOUT (where the test results appear) and STDERR (where the diagnostics appear) will stay in sync. The harness will display any diagnostics your tests emit on STDERR.

Caveat: this is a bit of a kludge. In particular note that if anything that appears on STDERR looks like a test result the test harness will get confused. Use this option only if you understand the consequences and can live with the risk.

--trap

The option will attempt to trap SIGINT (Ctrl-C) during a test run and display the test summary even if the run is interrupted

--state

You can ask to remember the state of previous test runs and select and/or order the tests to be run based on that saved state.
The switch requires an argument which must be a comma separated list of one or more of the following options.
"last"
Run the same tests as the last time the state was saved. This makes it possible, for example, to recreate the ordering of a shuffled test.
:
"failed"
Run only the tests that failed on the last run.
If you also specify the option newly passing tests will be excluded from subsequent runs.
:
"passed"
Run only the passed tests from last time. Useful to make sure that no new problems have been introduced.:
"all"
Run all tests in normal order. Multple options may be specified, so to run all tests with the failures from last time first:
:
"hot"
Run the tests that most recently failed first. The last failure time of each test is stored. The option causes tests to be run in most-recent- failure order.

Tests that have never failed will not be selected. To run all tests with the most recently failed first use

This combination of options may also be specified thus

:
"todo"
Run any tests with todos.:
"slow"
Run the tests in slowest to fastest order. This is useful in conjunction with the parallel testing switch to ensure that your slowest tests start running first.
:
"fast"
Run test tests in fastest to slowest order.:
"new"
Run the tests in newest to oldest order based on the modification times of the test scripts.:
"old"
Run the tests in oldest to newest order.:
"fresh"
Run those test scripts that have been modified since the last test run.:
"save"
Save the state on exit. The state is stored in a file called .prove (_prove on Windows and VMS) in the current directory.:
The switch may be used more than once.

--rules

The option is used to control which tests are run sequentially and which are run in parallel, if the option is specified. The option may be specified multiple times, and the order matters.

The most practical use is likely to specify that some tests are not ``parallel-ready. Since mentioning a file with --rules doesn't cause it to be selected to run as a test, you can ``set and forget some rules preferences in your .proverc file. Then you'll be able to take maximum advantage of the performance benefits of parallel testing, while some exceptions are still run in parallel.

--rules examples

--rules resolution

By default, all tests are eligible to be run in parallel. Specifying any of your own rules removes this one.:
``First match wins''. The first rule that matches a test will be the one that applies.:
Any test which does not match a rule will be run in sequence at the end of the run.:
The existence of a rule does not imply selecting a test. You must still specify the tests to run.:
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 in your Harness object.:

--rules Glob-style pattern matching

We implement our own glob-style pattern matching for --rules. Here are the supported patterns:

More advanced specifications for parallel vs sequence run rules

If you need more advanced management of what runs in parallel vs in sequence, see the associated 'rules' documentation in TAP::Harness and TAP::Parser::Scheduler. If what's possible directly through is not sufficient, you can write your own harness to access these features directly.

@INC

prove introduces a separation between ``options passed to the perl which runs prove and ``options passed to the perl which runs tests; this distinction is by design. Thus the perl which is running a test starts with the default . Additional library directories can be added via the environment variable, via -Ifoo in or via the option to prove.

Taint Mode

Normally when a Perl program is run in taint mode the contents of the environment variable do not appear in .
Because is often used during testing to add build directories to prove passes the names of any directories found in as -I switches. The net effect of this is that is honoured even when prove is run in taint mode.

FORMATTERS

You can load a custom TAP::Parser::Formatter:

SOURCE HANDLERS

You can load custom TAP::Parser::SourceHandlers, to change the way the parser interprets particular sources of TAP.

If you want to provide config to the source you can use:

Each option must specify a key/value pair separated by an . If an option can take multiple values, just specify it multiple times, as with the examples above. If the option should be a hash reference, specify the value as a second pair separated by a , as in the examples above (escape with a backslash).
All are combined into a hash, and passed to ``new'' in TAP::Harness's parameter.

See TAP::Parser::IteratorFactory for more details on how configuration is passed to SourceHandlers.

PLUGINS

Plugins can be loaded using the plugin syntax, eg:
This will search for a module named , or failing that, . If the plugin can't be found, will complain & exit.
You can pass arguments to your plugin by appending to the plugin name:

Please check individual plugin documentation for more details.

Available Plugins

For an up-to-date list of plugins available, please check CPAN:

<http://search.cpan.org/search?query=App%3A%3AProve+Plugin>

Writing Plugins

Please see ``PLUGINS'' in App::Prove.


Index

NAME

USAGE

OPTIONS

NOTES

.proverc

Reading from STDIN

Default Test Directory

Colored Test Output

Exit Code

Arguments to Tests

--exec

--merge

--trap

--state

--rules

@INC

Taint Mode

FORMATTERS

SOURCE HANDLERS

PLUGINS

Available Plugins

Writing Plugins


More Man Pages