Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / amd64 / man / man3 / Test::Harness.3
CommitLineData
920dae64
AT
1.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32
2.\"
3.\" Standard preamble:
4.\" ========================================================================
5.de Sh \" Subsection heading
6.br
7.if t .Sp
8.ne 5
9.PP
10\fB\\$1\fR
11.PP
12..
13.de Sp \" Vertical space (when we can't use .PP)
14.if t .sp .5v
15.if n .sp
16..
17.de Vb \" Begin verbatim text
18.ft CW
19.nf
20.ne \\$1
21..
22.de Ve \" End verbatim text
23.ft R
24.fi
25..
26.\" Set up some character translations and predefined strings. \*(-- will
27.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28.\" double quote, and \*(R" will give a right double quote. | will give a
29.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
30.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
31.\" expand to `' in nroff, nothing in troff, for use with C<>.
32.tr \(*W-|\(bv\*(Tr
33.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34.ie n \{\
35. ds -- \(*W-
36. ds PI pi
37. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
39. ds L" ""
40. ds R" ""
41. ds C` ""
42. ds C' ""
43'br\}
44.el\{\
45. ds -- \|\(em\|
46. ds PI \(*p
47. ds L" ``
48. ds R" ''
49'br\}
50.\"
51.\" If the F register is turned on, we'll generate index entries on stderr for
52.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53.\" entries marked with X<> in POD. Of course, you'll have to process the
54.\" output yourself in some meaningful fashion.
55.if \nF \{\
56. de IX
57. tm Index:\\$1\t\\n%\t"\\$2"
58..
59. nr % 0
60. rr F
61.\}
62.\"
63.\" For nroff, turn off justification. Always turn off hyphenation; it makes
64.\" way too many mistakes in technical documents.
65.hy 0
66.if n .na
67.\"
68.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69.\" Fear. Run. Save yourself. No user-serviceable parts.
70. \" fudge factors for nroff and troff
71.if n \{\
72. ds #H 0
73. ds #V .8m
74. ds #F .3m
75. ds #[ \f1
76. ds #] \fP
77.\}
78.if t \{\
79. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80. ds #V .6m
81. ds #F 0
82. ds #[ \&
83. ds #] \&
84.\}
85. \" simple accents for nroff and troff
86.if n \{\
87. ds ' \&
88. ds ` \&
89. ds ^ \&
90. ds , \&
91. ds ~ ~
92. ds /
93.\}
94.if t \{\
95. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101.\}
102. \" troff and (daisy-wheel) nroff accents
103.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110.ds ae a\h'-(\w'a'u*4/10)'e
111.ds Ae A\h'-(\w'A'u*4/10)'E
112. \" corrections for vroff
113.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115. \" for low resolution devices (crt and lpr)
116.if \n(.H>23 .if \n(.V>19 \
117\{\
118. ds : e
119. ds 8 ss
120. ds o a
121. ds d- d\h'-1'\(ga
122. ds D- D\h'-1'\(hy
123. ds th \o'bp'
124. ds Th \o'LP'
125. ds ae ae
126. ds Ae AE
127.\}
128.rm #[ #] #H #V #F C
129.\" ========================================================================
130.\"
131.IX Title "Test::Harness 3"
132.TH Test::Harness 3 "2001-09-21" "perl v5.8.8" "Perl Programmers Reference Guide"
133.SH "NAME"
134Test::Harness \- Run Perl standard test scripts with statistics
135.SH "VERSION"
136.IX Header "VERSION"
137Version 2.56
138.SH "SYNOPSIS"
139.IX Header "SYNOPSIS"
140.Vb 1
141\& use Test::Harness;
142.Ve
143.PP
144.Vb 1
145\& runtests(@test_files);
146.Ve
147.SH "DESCRIPTION"
148.IX Header "DESCRIPTION"
149\&\fB\s-1STOP\s0!\fR If all you want to do is write a test script, consider
150using Test::Simple. Test::Harness is the module that reads the
151output from Test::Simple, Test::More and other modules based on
152Test::Builder. You don't need to know about Test::Harness to use
153those modules.
154.PP
155Test::Harness runs tests and expects output from the test in a
156certain format. That format is called \s-1TAP\s0, the Test Anything
157Protocol. It is defined in Test::Harness::TAP.
158.PP
159\&\f(CW\*(C`Test::Harness::runtests(@tests)\*(C'\fR runs all the testscripts named
160as arguments and checks standard output for the expected strings
161in \s-1TAP\s0 format.
162.PP
163The \fIprove\fR utility is a thin wrapper around Test::Harness.
164.Sh "Taint mode"
165.IX Subsection "Taint mode"
166Test::Harness will honor the \f(CW\*(C`\-T\*(C'\fR or \f(CW\*(C`\-t\*(C'\fR in the #! line on your
167test files. So if you begin a test with:
168.PP
169.Vb 1
170\& #!perl -T
171.Ve
172.PP
173the test will be run with taint mode on.
174.Sh "Configuration variables."
175.IX Subsection "Configuration variables."
176These variables can be used to configure the behavior of
177Test::Harness. They are exported on request.
178.ie n .IP "$Test::Harness::Verbose" 4
179.el .IP "\f(CW$Test::Harness::Verbose\fR" 4
180.IX Item "$Test::Harness::Verbose"
181The package variable \f(CW$Test::Harness::Verbose\fR is exportable and can be
182used to let \f(CW\*(C`runtests()\*(C'\fR display the standard output of the script
183without altering the behavior otherwise. The \fIprove\fR utility's \f(CW\*(C`\-v\*(C'\fR
184flag will set this.
185.ie n .IP "$Test::Harness::switches" 4
186.el .IP "\f(CW$Test::Harness::switches\fR" 4
187.IX Item "$Test::Harness::switches"
188The package variable \f(CW$Test::Harness::switches\fR is exportable and can be
189used to set perl command line options used for running the test
190script(s). The default value is \f(CW\*(C`\-w\*(C'\fR. It overrides \f(CW\*(C`HARNESS_SWITCHES\*(C'\fR.
191.ie n .IP "$Test::Harness::Timer" 4
192.el .IP "\f(CW$Test::Harness::Timer\fR" 4
193.IX Item "$Test::Harness::Timer"
194If set to true, and \f(CW\*(C`Time::HiRes\*(C'\fR is available, print elapsed seconds
195after each test file.
196.Sh "Failure"
197.IX Subsection "Failure"
198When tests fail, analyze the summary report:
199.PP
200.Vb 12
201\& t/base..............ok
202\& t/nonumbers.........ok
203\& t/ok................ok
204\& t/test-harness......ok
205\& t/waterloo..........dubious
206\& Test returned status 3 (wstat 768, 0x300)
207\& DIED. FAILED tests 1, 3, 5, 7, 9, 11, 13, 15, 17, 19
208\& Failed 10/20 tests, 50.00% okay
209\& Failed Test Stat Wstat Total Fail Failed List of Failed
210\& -----------------------------------------------------------------------
211\& t/waterloo.t 3 768 20 10 50.00% 1 3 5 7 9 11 13 15 17 19
212\& Failed 1/5 test scripts, 80.00% okay. 10/44 subtests failed, 77.27% okay.
213.Ve
214.PP
215Everything passed but \fIt/waterloo.t\fR. It failed 10 of 20 tests and
216exited with non-zero status indicating something dubious happened.
217.PP
218The columns in the summary report mean:
219.IP "\fBFailed Test\fR" 4
220.IX Item "Failed Test"
221The test file which failed.
222.IP "\fBStat\fR" 4
223.IX Item "Stat"
224If the test exited with non\-zero, this is its exit status.
225.IP "\fBWstat\fR" 4
226.IX Item "Wstat"
227The wait status of the test.
228.IP "\fBTotal\fR" 4
229.IX Item "Total"
230Total number of tests expected to run.
231.IP "\fBFail\fR" 4
232.IX Item "Fail"
233Number which failed, either from \*(L"not ok\*(R" or because they never ran.
234.IP "\fBFailed\fR" 4
235.IX Item "Failed"
236Percentage of the total tests which failed.
237.IP "\fBList of Failed\fR" 4
238.IX Item "List of Failed"
239A list of the tests which failed. Successive failures may be
240abbreviated (ie. 15\-20 to indicate that tests 15, 16, 17, 18, 19 and
24120 failed).
242.Sh "Functions"
243.IX Subsection "Functions"
244Test::Harness currently only has one function, here it is.
245.IP "\fBruntests\fR" 4
246.IX Item "runtests"
247.Vb 1
248\& my $allok = runtests(@test_files);
249.Ve
250.Sp
251This runs all the given \fI@test_files\fR and divines whether they passed
252or failed based on their output to \s-1STDOUT\s0 (details above). It prints
253out each individual test which failed along with a summary report and
254a how long it all took.
255.Sp
256It returns true if everything was ok. Otherwise it will \f(CW\*(C`die()\*(C'\fR with
257one of the messages in the \s-1DIAGNOSTICS\s0 section.
258.SH "EXPORT"
259.IX Header "EXPORT"
260\&\f(CW&runtests\fR is exported by Test::Harness by default.
261.PP
262\&\f(CW$verbose\fR, \f(CW$switches\fR and \f(CW$debug\fR are exported upon request.
263.SH "DIAGNOSTICS"
264.IX Header "DIAGNOSTICS"
265.ie n .IP """All tests successful.\enFiles=%d, Tests=%d, %s""" 4
266.el .IP "\f(CWAll tests successful.\enFiles=%d, Tests=%d, %s\fR" 4
267.IX Item "All tests successful.nFiles=%d, Tests=%d, %s"
268If all tests are successful some statistics about the performance are
269printed.
270.ie n .IP """FAILED tests %s\en\etFailed %d/%d tests, %.2f%% okay.""" 4
271.el .IP "\f(CWFAILED tests %s\en\etFailed %d/%d tests, %.2f%% okay.\fR" 4
272.IX Item "FAILED tests %sntFailed %d/%d tests, %.2f%% okay."
273For any single script that has failing subtests statistics like the
274above are printed.
275.ie n .IP """Test returned status %d (wstat %d)""" 4
276.el .IP "\f(CWTest returned status %d (wstat %d)\fR" 4
277.IX Item "Test returned status %d (wstat %d)"
278Scripts that return a non-zero exit status, both \f(CW\*(C`$? >> 8\*(C'\fR
279and \f(CW$?\fR are printed in a message similar to the above.
280.ie n .IP """Failed 1 test, %.2f%% okay. %s""" 4
281.el .IP "\f(CWFailed 1 test, %.2f%% okay. %s\fR" 4
282.IX Item "Failed 1 test, %.2f%% okay. %s"
283.PD 0
284.ie n .IP """Failed %d/%d tests, %.2f%% okay. %s""" 4
285.el .IP "\f(CWFailed %d/%d tests, %.2f%% okay. %s\fR" 4
286.IX Item "Failed %d/%d tests, %.2f%% okay. %s"
287.PD
288If not all tests were successful, the script dies with one of the
289above messages.
290.ie n .IP """FAILED\-\-Further testing stopped: %s""" 4
291.el .IP "\f(CWFAILED\-\-Further testing stopped: %s\fR" 4
292.IX Item "FAILED--Further testing stopped: %s"
293If a single subtest decides that further testing will not make sense,
294the script dies with this message.
295.SH "ENVIRONMENT VARIABLES THAT TEST::HARNESS SETS"
296.IX Header "ENVIRONMENT VARIABLES THAT TEST::HARNESS SETS"
297Test::Harness sets these before executing the individual tests.
298.ie n .IP """HARNESS_ACTIVE""" 4
299.el .IP "\f(CWHARNESS_ACTIVE\fR" 4
300.IX Item "HARNESS_ACTIVE"
301This is set to a true value. It allows the tests to determine if they
302are being executed through the harness or by any other means.
303.ie n .IP """HARNESS_VERSION""" 4
304.el .IP "\f(CWHARNESS_VERSION\fR" 4
305.IX Item "HARNESS_VERSION"
306This is the version of Test::Harness.
307.SH "ENVIRONMENT VARIABLES THAT AFFECT TEST::HARNESS"
308.IX Header "ENVIRONMENT VARIABLES THAT AFFECT TEST::HARNESS"
309.ie n .IP """HARNESS_COLUMNS""" 4
310.el .IP "\f(CWHARNESS_COLUMNS\fR" 4
311.IX Item "HARNESS_COLUMNS"
312This value will be used for the width of the terminal. If it is not
313set then it will default to \f(CW\*(C`COLUMNS\*(C'\fR. If this is not set, it will
314default to 80. Note that users of Bourne-sh based shells will need to
315\&\f(CW\*(C`export COLUMNS\*(C'\fR for this module to use that variable.
316.ie n .IP """HARNESS_COMPILE_TEST""" 4
317.el .IP "\f(CWHARNESS_COMPILE_TEST\fR" 4
318.IX Item "HARNESS_COMPILE_TEST"
319When true it will make harness attempt to compile the test using
320\&\f(CW\*(C`perlcc\*(C'\fR before running it.
321.Sp
322\&\fB\s-1NOTE\s0\fR This currently only works when sitting in the perl source
323directory!
324.ie n .IP """HARNESS_DEBUG""" 4
325.el .IP "\f(CWHARNESS_DEBUG\fR" 4
326.IX Item "HARNESS_DEBUG"
327If true, Test::Harness will print debugging information about itself as
328it runs the tests. This is different from \f(CW\*(C`HARNESS_VERBOSE\*(C'\fR, which prints
329the output from the test being run. Setting \f(CW$Test::Harness::Debug\fR will
330override this, or you can use the \f(CW\*(C`\-d\*(C'\fR switch in the \fIprove\fR utility.
331.ie n .IP """HARNESS_FILELEAK_IN_DIR""" 4
332.el .IP "\f(CWHARNESS_FILELEAK_IN_DIR\fR" 4
333.IX Item "HARNESS_FILELEAK_IN_DIR"
334When set to the name of a directory, harness will check after each
335test whether new files appeared in that directory, and report them as
336.Sp
337.Vb 1
338\& LEAKED FILES: scr.tmp 0 my.db
339.Ve
340.Sp
341If relative, directory name is with respect to the current directory at
342the moment \fIruntests()\fR was called. Putting absolute path into
343\&\f(CW\*(C`HARNESS_FILELEAK_IN_DIR\*(C'\fR may give more predictable results.
344.ie n .IP """HARNESS_IGNORE_EXITCODE""" 4
345.el .IP "\f(CWHARNESS_IGNORE_EXITCODE\fR" 4
346.IX Item "HARNESS_IGNORE_EXITCODE"
347Makes harness ignore the exit status of child processes when defined.
348.ie n .IP """HARNESS_NOTTY""" 4
349.el .IP "\f(CWHARNESS_NOTTY\fR" 4
350.IX Item "HARNESS_NOTTY"
351When set to a true value, forces it to behave as though \s-1STDOUT\s0 were
352not a console. You may need to set this if you don't want harness to
353output more frequent progress messages using carriage returns. Some
354consoles may not handle carriage returns properly (which results in a
355somewhat messy output).
356.ie n .IP """HARNESS_PERL""" 4
357.el .IP "\f(CWHARNESS_PERL\fR" 4
358.IX Item "HARNESS_PERL"
359Usually your tests will be run by \f(CW$^X\fR, the currently-executing Perl.
360However, you may want to have it run by a different executable, such as
361a threading perl, or a different version.
362.Sp
363If you're using the \fIprove\fR utility, you can use the \f(CW\*(C`\-\-perl\*(C'\fR switch.
364.ie n .IP """HARNESS_PERL_SWITCHES""" 4
365.el .IP "\f(CWHARNESS_PERL_SWITCHES\fR" 4
366.IX Item "HARNESS_PERL_SWITCHES"
367Its value will be prepended to the switches used to invoke perl on
368each test. For example, setting \f(CW\*(C`HARNESS_PERL_SWITCHES\*(C'\fR to \f(CW\*(C`\-W\*(C'\fR will
369run all tests with all warnings enabled.
370.ie n .IP """HARNESS_VERBOSE""" 4
371.el .IP "\f(CWHARNESS_VERBOSE\fR" 4
372.IX Item "HARNESS_VERBOSE"
373If true, Test::Harness will output the verbose results of running
374its tests. Setting \f(CW$Test::Harness::verbose\fR will override this,
375or you can use the \f(CW\*(C`\-v\*(C'\fR switch in the \fIprove\fR utility.
376.SH "EXAMPLE"
377.IX Header "EXAMPLE"
378Here's how Test::Harness tests itself
379.PP
380.Vb 10
381\& $ cd ~/src/devel/Test-Harness
382\& $ perl -Mblib -e 'use Test::Harness qw(&runtests $verbose);
383\& $verbose=0; runtests @ARGV;' t/*.t
384\& Using /home/schwern/src/devel/Test-Harness/blib
385\& t/base..............ok
386\& t/nonumbers.........ok
387\& t/ok................ok
388\& t/test-harness......ok
389\& All tests successful.
390\& Files=4, Tests=24, 2 wallclock secs ( 0.61 cusr + 0.41 csys = 1.02 CPU)
391.Ve
392.SH "SEE ALSO"
393.IX Header "SEE ALSO"
394The included \fIprove\fR utility for running test scripts from the command line,
395Test and Test::Simple for writing test scripts, Benchmark for
396the underlying timing routines, and Devel::Cover for test coverage
397analysis.
398.SH "TODO"
399.IX Header "TODO"
400Provide a way of running tests quietly (ie. no printing) for automated
401validation of tests. This will probably take the form of a version
402of \fIruntests()\fR which rather than printing its output returns raw data
403on the state of the tests. (Partially done in Test::Harness::Straps)
404.PP
405Document the format.
406.PP
407Fix \s-1HARNESS_COMPILE_TEST\s0 without breaking its core usage.
408.PP
409Figure a way to report test names in the failure summary.
410.PP
411Rework the test summary so long test names are not truncated as badly.
412(Partially done with new skip test styles)
413.PP
414Add option for coverage analysis.
415.PP
416Trap \s-1STDERR\s0.
417.PP
418Implement Straps \fItotal_results()\fR
419.PP
420Remember exit code
421.PP
422Completely redo the print summary code.
423.PP
424Implement Straps callbacks. (experimentally implemented)
425.PP
426Straps\->\fIanalyze_file()\fR not taint clean, don't know if it can be
427.PP
428Fix that damned \s-1VMS\s0 nit.
429.PP
430\&\s-1HARNESS_TODOFAIL\s0 to display \s-1TODO\s0 failures
431.PP
432Add a test for verbose.
433.PP
434Change internal list of test results to a hash.
435.PP
436Fix stats display when there's an overrun.
437.PP
438Fix so perls with spaces in the filename work.
439.PP
440Keeping whittling away at \fI_run_all_tests()\fR
441.PP
442Clean up how the summary is printed. Get rid of those damned formats.
443.SH "BUGS"
444.IX Header "BUGS"
445\&\s-1HARNESS_COMPILE_TEST\s0 currently assumes it's run from the Perl source
446directory.
447.PP
448Please use the \s-1CPAN\s0 bug ticketing system at <http://rt.cpan.org/>.
449You can also mail bugs, fixes and enhancements to
450\&\f(CW\*(C`<bug\-test\-harness\*(C'\fR at \f(CW\*(C`rt.cpan.org>\*(C'\fR.
451.SH "AUTHORS"
452.IX Header "AUTHORS"
453Either Tim Bunce or Andreas Koenig, we don't know. What we know for
454sure is, that it was inspired by Larry Wall's \s-1TEST\s0 script that came
455with perl distributions for ages. Numerous anonymous contributors
456exist. Andreas Koenig held the torch for many years, and then
457Michael G Schwern.
458.PP
459Current maintainer is Andy Lester \f(CW\*(C`<andy at petdance.com>\*(C'\fR.
460.SH "COPYRIGHT"
461.IX Header "COPYRIGHT"
462Copyright 2002\-2005
463by Michael G Schwern \f(CW\*(C`<schwern at pobox.com>\*(C'\fR,
464Andy Lester \f(CW\*(C`<andy at petdance.com>\*(C'\fR.
465.PP
466This program is free software; you can redistribute it and/or
467modify it under the same terms as Perl itself.
468.PP
469See <http://www.perl.com/perl/misc/Artistic.html>.