.\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13 .\" .\" Standard preamble: .\" ======================================================================== .de Sh \" Subsection heading .br .if t .Sp .ne 5 .PP \fB\\$1\fR .PP .. .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. | will give a .\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to .\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C' .\" expand to `' in nroff, nothing in troff, for use with C<>. .tr \(*W-|\(bv\*(Tr .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .\" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .hy 0 .if n .na .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Test::Harness 3" .TH Test::Harness 3 "2002-06-01" "perl v5.8.0" "Perl Programmers Reference Guide" .SH "NAME" Test::Harness \- run perl standard test scripts with statistics .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Test::Harness; .Ve .PP .Vb 1 \& runtests(@test_files); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fB\s-1STOP\s0!\fR If all you want to do is write a test script, consider using Test::Simple. Otherwise, read on. .PP (By using the Test module, you can write test scripts without knowing the exact output this module expects. However, if you need to know the specifics, read on!) .PP Perl test scripts print to standard output \f(CW"ok N"\fR for each single test, where \f(CW\*(C`N\*(C'\fR is an increasing sequence of integers. The first line output by a standard test script is \f(CW"1..M"\fR with \f(CW\*(C`M\*(C'\fR being the number of tests that should be run within the test script. Test::Harness::runtests(@tests) runs all the testscripts named as arguments and checks standard output for the expected \&\f(CW"ok N"\fR strings. .PP After all tests have been performed, \fIruntests()\fR prints some performance statistics that are computed by the Benchmark module. .Sh "The test script output" .IX Subsection "The test script output" The following explains how Test::Harness interprets the output of your test program. .IP "\fB'1..M'\fR" 4 .IX Item "'1..M'" This header tells how many tests there will be. For example, \f(CW1..10\fR means you plan on running 10 tests. This is a safeguard in case your test dies quietly in the middle of its run. .Sp It should be the first non-comment line output by your test program. .Sp In certain instances, you may not know how many tests you will ultimately be running. In this case, it is permitted for the 1..M header to appear as the \fBlast\fR line output by your test (again, it can be followed by further comments). .Sp Under \fBno\fR circumstances should 1..M appear in the middle of your output or more than once. .IP "\fB'ok', 'not ok'. Ok?\fR" 4 .IX Item "'ok', 'not ok'. Ok?" Any output from the testscript to standard error is ignored and bypassed, thus will be seen by the user. Lines written to standard output containing \f(CW\*(C`/^(not\es+)?ok\eb/\*(C'\fR are interpreted as feedback for \&\fIruntests()\fR. All other lines are discarded. .Sp \&\f(CW\*(C`/^not ok/\*(C'\fR indicates a failed test. \f(CW\*(C`/^ok/\*(C'\fR is a successful test. .IP "\fBtest numbers\fR" 4 .IX Item "test numbers" Perl normally expects the 'ok' or 'not ok' to be followed by a test number. It is tolerated if the test numbers after 'ok' are omitted. In this case Test::Harness maintains temporarily its own counter until the script supplies test numbers again. So the following test script .Sp .Vb 8 \& print <> 8\*(C'\fR and \f(CW$?\fR are printed in a message similar to the above. .ie n .IP """Failed 1 test, %.2f%% okay. %s""" 4 .el .IP "\f(CWFailed 1 test, %.2f%% okay. %s\fR" 4 .IX Item "Failed 1 test, %.2f%% okay. %s" .PD 0 .ie n .IP """Failed %d/%d tests, %.2f%% okay. %s""" 4 .el .IP "\f(CWFailed %d/%d tests, %.2f%% okay. %s\fR" 4 .IX Item "Failed %d/%d tests, %.2f%% okay. %s" .PD If not all tests were successful, the script dies with one of the above messages. .ie n .IP """FAILED\-\-Further testing stopped: %s""" 4 .el .IP "\f(CWFAILED\-\-Further testing stopped: %s\fR" 4 .IX Item "FAILED--Further testing stopped: %s" If a single subtest decides that further testing will not make sense, the script dies with this message. .SH "ENVIRONMENT" .IX Header "ENVIRONMENT" .ie n .IP """HARNESS_ACTIVE""" 4 .el .IP "\f(CWHARNESS_ACTIVE\fR" 4 .IX Item "HARNESS_ACTIVE" Harness sets this before executing the individual tests. This allows the tests to determine if they are being executed through the harness or by any other means. .ie n .IP """HARNESS_COLUMNS""" 4 .el .IP "\f(CWHARNESS_COLUMNS\fR" 4 .IX Item "HARNESS_COLUMNS" This value will be used for the width of the terminal. If it is not set then it will default to \f(CW\*(C`COLUMNS\*(C'\fR. If this is not set, it will default to 80. Note that users of Bourne-sh based shells will need to \&\f(CW\*(C`export COLUMNS\*(C'\fR for this module to use that variable. .ie n .IP """HARNESS_COMPILE_TEST""" 4 .el .IP "\f(CWHARNESS_COMPILE_TEST\fR" 4 .IX Item "HARNESS_COMPILE_TEST" When true it will make harness attempt to compile the test using \&\f(CW\*(C`perlcc\*(C'\fR before running it. .Sp \&\fB\s-1NOTE\s0\fR This currently only works when sitting in the perl source directory! .ie n .IP """HARNESS_FILELEAK_IN_DIR""" 4 .el .IP "\f(CWHARNESS_FILELEAK_IN_DIR\fR" 4 .IX Item "HARNESS_FILELEAK_IN_DIR" When set to the name of a directory, harness will check after each test whether new files appeared in that directory, and report them as .Sp .Vb 1 \& LEAKED FILES: scr.tmp 0 my.db .Ve .Sp If relative, directory name is with respect to the current directory at the moment \fIruntests()\fR was called. Putting absolute path into \&\f(CW\*(C`HARNESS_FILELEAK_IN_DIR\*(C'\fR may give more predictable results. .ie n .IP """HARNESS_IGNORE_EXITCODE""" 4 .el .IP "\f(CWHARNESS_IGNORE_EXITCODE\fR" 4 .IX Item "HARNESS_IGNORE_EXITCODE" Makes harness ignore the exit status of child processes when defined. .ie n .IP """HARNESS_NOTTY""" 4 .el .IP "\f(CWHARNESS_NOTTY\fR" 4 .IX Item "HARNESS_NOTTY" When set to a true value, forces it to behave as though \s-1STDOUT\s0 were not a console. You may need to set this if you don't want harness to output more frequent progress messages using carriage returns. Some consoles may not handle carriage returns properly (which results in a somewhat messy output). .ie n .IP """HARNESS_PERL_SWITCHES""" 4 .el .IP "\f(CWHARNESS_PERL_SWITCHES\fR" 4 .IX Item "HARNESS_PERL_SWITCHES" Its value will be prepended to the switches used to invoke perl on each test. For example, setting \f(CW\*(C`HARNESS_PERL_SWITCHES\*(C'\fR to \f(CW\*(C`\-W\*(C'\fR will run all tests with all warnings enabled. .ie n .IP """HARNESS_VERBOSE""" 4 .el .IP "\f(CWHARNESS_VERBOSE\fR" 4 .IX Item "HARNESS_VERBOSE" If true, Test::Harness will output the verbose results of running its tests. Setting \f(CW$Test::Harness::verbose\fR will override this. .SH "EXAMPLE" .IX Header "EXAMPLE" Here's how Test::Harness tests itself .PP .Vb 10 \& $ cd ~/src/devel/Test-Harness \& $ perl -Mblib -e 'use Test::Harness qw(&runtests $verbose); \& $verbose=0; runtests @ARGV;' t/*.t \& Using /home/schwern/src/devel/Test-Harness/blib \& t/base..............ok \& t/nonumbers.........ok \& t/ok................ok \& t/test-harness......ok \& All tests successful. \& Files=4, Tests=24, 2 wallclock secs ( 0.61 cusr + 0.41 csys = 1.02 CPU) .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" Test and Test::Simple for writing test scripts, Benchmark for the underlying timing routines, Devel::CoreStack to generate core dumps from failed tests and Devel::Cover for test coverage analysis. .SH "AUTHORS" .IX Header "AUTHORS" Either Tim Bunce or Andreas Koenig, we don't know. What we know for sure is, that it was inspired by Larry Wall's \s-1TEST\s0 script that came with perl distributions for ages. Numerous anonymous contributors exist. Andreas Koenig held the torch for many years. .PP Current maintainer is Michael G Schwern .SH "TODO" .IX Header "TODO" Provide a way of running tests quietly (ie. no printing) for automated validation of tests. This will probably take the form of a version of \fIruntests()\fR which rather than printing its output returns raw data on the state of the tests. (Partially done in Test::Harness::Straps) .PP Fix \s-1HARNESS_COMPILE_TEST\s0 without breaking its core usage. .PP Figure a way to report test names in the failure summary. .PP Rework the test summary so long test names are not truncated as badly. (Partially done with new skip test styles) .PP Deal with \s-1VMS\s0's \*(L"not \enok 4\en\*(R" mistake. .PP Add option for coverage analysis. .SH "BUGS" .IX Header "BUGS" \&\s-1HARNESS_COMPILE_TEST\s0 currently assumes it's run from the Perl source directory.