Upgrade to Test::Harness 3.14
[p5sagit/p5-mst-13.2.git] / ext / Test / Harness / bin / prove
CommitLineData
e4fc8a1e 1#!/usr/bin/perl -w
2
3use strict;
b965d173 4use App::Prove;
e4fc8a1e 5
b965d173 6my $app = App::Prove->new;
7$app->process_args(@ARGV);
f7c69158 8exit( $app->run ? 0 : 1 );
e4fc8a1e 9
e4fc8a1e 10__END__
11
12=head1 NAME
13
b965d173 14prove - Run tests through a TAP harness.
e4fc8a1e 15
b965d173 16=head1 USAGE
e4fc8a1e 17
b965d173 18 prove [options] [files or directories]
e4fc8a1e 19
20f9f807 20=head1 OPTIONS
e4fc8a1e 21
b965d173 22Boolean options:
e4fc8a1e 23
b965d173 24 -v, --verbose Print all test lines.
25 -l, --lib Add 'lib' to the path for your tests (-Ilib).
f7c69158 26 -b, --blib Add 'blib/lib' and 'blib/arch' to the path for your tests
b965d173 27 -s, --shuffle Run the tests in random order.
28 -c, --color Colored test output (default).
29 --nocolor Do not color test output.
27fc0087 30 --count Show the X/Y test count when not verbose (default)
31 --nocount Disable the X/Y test count.
41d86c6b 32 -D --dry Dry run. Show test that would have run.
f7c69158 33 --ext Set the extension for tests (default '.t')
b965d173 34 -f, --failures Only show failed tests.
f7c69158 35 --fork Fork to run harness in multiple processes.
36 --ignore-exit Ignore exit status from test scripts.
b965d173 37 -m, --merge Merge test scripts' STDERR with their STDOUT.
38 -r, --recurse Recursively descend into directories.
39 --reverse Run the tests in reverse order.
40 -q, --quiet Suppress some test output while running tests.
41 -Q, --QUIET Only print summary results.
42 -p, --parse Show full list of TAP parse errors, if any.
43 --directives Only show results with TODO or SKIP directives.
44 --timer Print elapsed time after each test.
45 -T Enable tainting checks.
46 -t Enable tainting warnings.
47 -W Enable fatal warnings.
48 -w Enable warnings.
49 -h, --help Display this help
50 -?, Display this help
51 -H, --man Longer manpage for prove
52 --norc Don't process default .proverc
e4fc8a1e 53
b965d173 54Options that take arguments:
e4fc8a1e 55
b965d173 56 -I Library paths to include.
57 -P Load plugin (searches App::Prove::Plugin::*.)
58 -M Load a module.
59 -e, --exec Interpreter to run the tests ('' for compiled tests.)
60 --harness Define test harness to use. See TAP::Harness.
61 --formatter Result formatter to use. See TAP::Harness.
62 -a, --archive Store the resulting TAP in an archive file.
63 -j, --jobs N Run N test jobs in parallel (try 9.)
64 --state=opts Control prove's persistent state.
65 --rc=rcfile Process options from rcfile
e4fc8a1e 66
b965d173 67=head1 NOTES
e4fc8a1e 68
b965d173 69=head2 .proverc
e4fc8a1e 70
b965d173 71If F<~/.proverc> or F<./.proverc> exist they will be read and any
72options they contain processed before the command line options. Options
73in F<.proverc> are specified in the same way as command line options:
e4fc8a1e 74
b965d173 75 # .proverc
76 --state=hot,fast,save
77 -j9 --fork
e4fc8a1e 78
b965d173 79Additional option files may be specified with the C<--rc> option.
80Default option file processing is disabled by the C<--norc> option.
e4fc8a1e 81
b965d173 82Under Windows and VMS the option file is named F<_proverc> rather than
83F<.proverc> and is sought only in the current directory.
e4fc8a1e 84
b965d173 85=head2 Reading from C<STDIN>
e4fc8a1e 86
b965d173 87If you have a list of tests (or URLs, or anything else you want to test) in a
88file, you can add them to your tests by using a '-':
e4fc8a1e 89
b965d173 90 prove - < my_list_of_things_to_test.txt
e4fc8a1e 91
b965d173 92See the C<README> in the C<examples> directory of this distribution.
e4fc8a1e 93
b965d173 94=head2 Default Test Directory
e4fc8a1e 95
b965d173 96If no files or directories are supplied, C<prove> looks for all files
97matching the pattern C<t/*.t>.
e4fc8a1e 98
b965d173 99=head2 Colored Test Output
e4fc8a1e 100
b965d173 101Colored test output is the default, but if output is not to a
102terminal, color is disabled. You can override this by adding the
103C<--color> switch.
e4fc8a1e 104
b965d173 105Color support requires L<Term::ANSIColor> on Unix-like platforms and
106L<Win32::Console> windows. If the necessary module is not installed
107colored output will not be available.
e4fc8a1e 108
b965d173 109=head2 Arguments to Tests
e4fc8a1e 110
b965d173 111It is possible to supply arguments to tests. To do so separate them from
112prove's own arguments with the arisdottle, '::'. For example
e4fc8a1e 113
b965d173 114 prove -v t/mytest.t :: --url http://example.com
115
116would run F<t/mytest.t> with the options '--url http://example.com'.
117When running multiple tests they will each receive the same arguments.
e4fc8a1e 118
b965d173 119=head2 C<--exec>
e4fc8a1e 120
b965d173 121Normally you can just pass a list of Perl tests and the harness will know how
122to execute them. However, if your tests are not written in Perl or if you
123want all tests invoked exactly the same way, use the C<-e>, or C<--exec>
124switch:
e4fc8a1e 125
b965d173 126 prove --exec '/usr/bin/ruby -w' t/
127 prove --exec '/usr/bin/perl -Tw -mstrict -Ilib' t/
128 prove --exec '/path/to/my/customer/exec'
e4fc8a1e 129
b965d173 130=head2 C<--merge>
e4fc8a1e 131
b965d173 132If you need to make sure your diagnostics are displayed in the correct
133order relative to test results you can use the C<--merge> option to
134merge the test scripts' STDERR into their STDOUT.
e4fc8a1e 135
b965d173 136This guarantees that STDOUT (where the test results appear) and STDOUT
137(where the diagnostics appear) will stay in sync. The harness will
138display any diagnostics your tests emit on STDERR.
e4fc8a1e 139
b965d173 140Caveat: this is a bit of a kludge. In particular note that if anything
141that appears on STDERR looks like a test result the test harness will
142get confused. Use this option only if you understand the consequences
143and can live with the risk.
e4fc8a1e 144
b965d173 145=head2 C<--state>
e4fc8a1e 146
b965d173 147You can ask C<prove> to remember the state of previous test runs and
27fc0087 148select and/or order the tests to be run based on that saved state.
e4fc8a1e 149
b965d173 150The C<--state> switch requires an argument which must be a comma
151separated list of one or more of the following options.
60e33a80 152
b965d173 153=over
60e33a80 154
b965d173 155=item C<last>
e4fc8a1e 156
b965d173 157Run the same tests as the last time the state was saved. This makes it
158possible, for example, to recreate the ordering of a shuffled test.
20f9f807 159
b965d173 160 # Run all tests in random order
161 $ prove -b --state=save --shuffle
20f9f807 162
b965d173 163 # Run them again in the same order
164 $ prove -b --state=last
e4fc8a1e 165
b965d173 166=item C<failed>
e4fc8a1e 167
b965d173 168Run only the tests that failed on the last run.
e4fc8a1e 169
b965d173 170 # Run all tests
69f36734 171 $ prove -b --state=save
b965d173 172
173 # Run failures
174 $ prove -b --state=failed
e4fc8a1e 175
b965d173 176If you also specify the C<save> option newly passing tests will be
177excluded from subsequent runs.
5b1ebecd 178
b965d173 179 # Repeat until no more failures
180 $ prove -b --state=failed,save
5b1ebecd 181
b965d173 182=item C<passed>
e4fc8a1e 183
b965d173 184Run only the passed tests from last time. Useful to make sure that no
185new problems have been introduced.
e4fc8a1e 186
b965d173 187=item C<all>
e4fc8a1e 188
b965d173 189Run all tests in normal order. Multple options may be specified, so to
190run all tests with the failures from last time first:
e4fc8a1e 191
b965d173 192 $ prove -b --state=failed,all,save
43ef773b 193
b965d173 194=item C<hot>
43ef773b 195
b965d173 196Run the tests that most recently failed first. The last failure time of
197each test is stored. The C<hot> option causes tests to be run in most-recent-
198failure order.
e4fc8a1e 199
b965d173 200 $ prove -b --state=hot,save
e4fc8a1e 201
b965d173 202Tests that have never failed will not be selected. To run all tests with
203the most recently failed first use
e4fc8a1e 204
b965d173 205 $ prove -b --state=hot,all,save
e4fc8a1e 206
b965d173 207This combination of options may also be specified thus
e4fc8a1e 208
b965d173 209 $ prove -b --state=adrian
e4fc8a1e 210
b965d173 211=item C<todo>
e4fc8a1e 212
b965d173 213Run any tests with todos.
e4fc8a1e 214
b965d173 215=item C<slow>
e4fc8a1e 216
b965d173 217Run the tests in slowest to fastest order. This is useful in conjunction
218with the C<-j> parallel testing switch to ensure that your slowest tests
219start running first.
e4fc8a1e 220
b965d173 221 $ prove -b --state=slow -j9
222
223=item C<fast>
e4fc8a1e 224
b965d173 225Run test tests in fastest to slowest order.
e4fc8a1e 226
b965d173 227=item C<new>
e4fc8a1e 228
27fc0087 229Run the tests in newest to oldest order based on the modification times
230of the test scripts.
e4fc8a1e 231
b965d173 232=item C<old>
e4fc8a1e 233
b965d173 234Run the tests in oldest to newest order.
e4fc8a1e 235
27fc0087 236=item C<fresh>
237
238Run those test scripts that have been modified since the last test run.
239
b965d173 240=item C<save>
241
242Save the state on exit. The state is stored in a file called F<.prove>
243(F<_prove> on Windows and VMS) in the current directory.
244
245=back
246
247The C<--state> switch may be used more than once.
248
249 $ prove -b --state=hot --state=all,save
e4fc8a1e 250
bd3ac2f1 251=head2 Taint Mode
252
253Normally when a Perl program is run in taint mode the contents of the
254C<PERL5LIB> environment variable do not appear in C<@INC>.
255
256Because C<PERL5LIB> is often used during testing to add build directories
257to C<@INC> prove (actually L<TAP::Parser::Source::Perl>) passes the
258names of any directories found in C<PERL5LIB> as -I switches. The net
259effect of this is that C<PERL5LIB> is honoured even when prove is run in
260taint mode.
261
e4fc8a1e 262=cut
b965d173 263
264# vim:ts=4:sw=4:et:sta