Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / amd64 / man / man3 / Test::Harness::TAP.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::TAP 3"
132.TH Test::Harness::TAP 3 "2001-09-21" "perl v5.8.8" "Perl Programmers Reference Guide"
133.SH "NAME"
134Test::Harness::TAP \- Documentation for the TAP format
135.SH "SYNOPSIS"
136.IX Header "SYNOPSIS"
137\&\s-1TAP\s0, the Test Anything Protocol, is Perl's simple text-based interface
138between testing modules such as Test::More and the test harness
139Test::Harness.
140.SH "TODO"
141.IX Header "TODO"
142Exit code of the process.
143.SH "THE TAP FORMAT"
144.IX Header "THE TAP FORMAT"
145\&\s-1TAP\s0's general format is:
146.PP
147.Vb 7
148\& 1..N
149\& ok 1 Description # Directive
150\& # Diagnostic
151\& ....
152\& ok 47 Description
153\& ok 48 Description
154\& more tests....
155.Ve
156.PP
157For example, a test file's output might look like:
158.PP
159.Vb 5
160\& 1..4
161\& ok 1 - Input file opened
162\& not ok 2 - First line of the input valid
163\& ok 3 - Read the rest of the file
164\& not ok 4 - Summarized correctly # TODO Not written yet
165.Ve
166.SH "HARNESS BEHAVIOR"
167.IX Header "HARNESS BEHAVIOR"
168In this document, the \*(L"harness\*(R" is any program analyzing \s-1TAP\s0 output.
169Typically this will be Perl's \fIprove\fR program, or the underlying
170\&\f(CW\*(C`Test::Harness::runtests\*(C'\fR subroutine.
171.PP
172A harness must only read \s-1TAP\s0 output from standard output and not
173from standard error. Lines written to standard output matching
174\&\f(CW\*(C`/^(not )?ok\eb/\*(C'\fR must be interpreted as test lines. All other
175lines must not be considered test output.
176.SH "TESTS LINES AND THE PLAN"
177.IX Header "TESTS LINES AND THE PLAN"
178.Sh "The plan"
179.IX Subsection "The plan"
180The plan tells how many tests will be run, or how many tests have
181run. It's a check that the test file hasn't stopped prematurely.
182It must appear once, whether at the beginning or end of the output.
183.PP
184The plan is usually the first line of \s-1TAP\s0 output and it specifies how
185many test points are to follow. For example,
186.PP
187.Vb 1
188\& 1..10
189.Ve
190.PP
191means you plan on running 10 tests. This is a safeguard in case your test
192file dies silently in the middle of its run. The plan is optional but if
193there is a plan before the test points it must be the first non-diagnostic
194line output by the test file.
195.PP
196In certain instances a test file may not know how many test points
197it will ultimately be running. In this case the plan can be the last
198non-diagnostic line in the output.
199.PP
200The plan cannot appear in the middle of the output, nor can it appear more
201than once.
202.Sh "The test line"
203.IX Subsection "The test line"
204The core of \s-1TAP\s0 is the test line. A test file prints one test line test
205point executed. There must be at least one test line in \s-1TAP\s0 output. Each
206test line comprises the following elements:
207.ie n .IP "* ""ok""\fR or \f(CW""not ok""" 4
208.el .IP "* \f(CWok\fR or \f(CWnot ok\fR" 4
209.IX Item "ok or not ok"
210This tells whether the test point passed or failed. It must be
211at the beginning of the line. \f(CW\*(C`/^not ok/\*(C'\fR indicates a failed test
212point. \f(CW\*(C`/^ok/\*(C'\fR is a successful test point. This is the only mandatory
213part of the line.
214.Sp
215Note that unlike the Directives below, \f(CW\*(C`ok\*(C'\fR and \f(CW\*(C`not ok\*(C'\fR are
216case\-sensitive.
217.IP "* Test number" 4
218.IX Item "Test number"
219\&\s-1TAP\s0 expects the \f(CW\*(C`ok\*(C'\fR or \f(CW\*(C`not ok\*(C'\fR to be followed by a test point
220number. If there is no number the harness must maintain
221its own counter until the script supplies test numbers again. So
222the following test output
223.Sp
224.Vb 6
225\& 1..6
226\& not ok
227\& ok
228\& not ok
229\& ok
230\& ok
231.Ve
232.Sp
233has five tests. The sixth is missing. Test::Harness will generate
234.Sp
235.Vb 2
236\& FAILED tests 1, 3, 6
237\& Failed 3/6 tests, 50.00% okay
238.Ve
239.IP "* Description" 4
240.IX Item "Description"
241Any text after the test number but before a \f(CW\*(C`#\*(C'\fR is the description of
242the test point.
243.Sp
244.Vb 1
245\& ok 42 this is the description of the test
246.Ve
247.Sp
248Descriptions should not begin with a digit so that they are not confused
249with the test point number.
250.Sp
251The harness may do whatever it wants with the description.
252.IP "* Directive" 4
253.IX Item "Directive"
254The test point may include a directive, following a hash on the
255test line. There are currently two directives allowed: \f(CW\*(C`TODO\*(C'\fR and
256\&\f(CW\*(C`SKIP\*(C'\fR. These are discussed below.
257.PP
258To summarize:
259.IP "* ok/not ok (required)" 4
260.IX Item "ok/not ok (required)"
261.PD 0
262.IP "* Test number (recommended)" 4
263.IX Item "Test number (recommended)"
264.IP "* Description (recommended)" 4
265.IX Item "Description (recommended)"
266.IP "* Directive (only when necessary)" 4
267.IX Item "Directive (only when necessary)"
268.PD
269.SH "DIRECTIVES"
270.IX Header "DIRECTIVES"
271Directives are special notes that follow a \f(CW\*(C`#\*(C'\fR on the test line.
272Only two are currently defined: \f(CW\*(C`TODO\*(C'\fR and \f(CW\*(C`SKIP\*(C'\fR. Note that
273these two keywords are not case\-sensitive.
274.Sh "\s-1TODO\s0 tests"
275.IX Subsection "TODO tests"
276If the directive starts with \f(CW\*(C`# TODO\*(C'\fR, the test is counted as a
277todo test, and the text after \f(CW\*(C`TODO\*(C'\fR is the explanation.
278.PP
279.Vb 1
280\& not ok 13 # TODO bend space and time
281.Ve
282.PP
283Note that if the \s-1TODO\s0 has an explanation it must be separated from
284\&\f(CW\*(C`TODO\*(C'\fR by a space.
285.PP
286These tests represent a feature to be implemented or a bug to be fixed
287and act as something of an executable \*(L"things to do\*(R" list. They are
288\&\fBnot\fR expected to succeed. Should a todo test point begin succeeding,
289the harness should report it as a bonus. This indicates that whatever
290you were supposed to do has been done and you should promote this to a
291normal test point.
292.Sh "Skipping tests"
293.IX Subsection "Skipping tests"
294If the directive starts with \f(CW\*(C`# SKIP\*(C'\fR, the test is counted as having
295been skipped. If the whole test file succeeds, the count of skipped
296tests is included in the generated output. The harness should report
297the text after \f(CW\*(C` # SKIP\eS*\es+\*(C'\fR as a reason for skipping.
298.PP
299.Vb 1
300\& ok 23 # skip Insufficient flogiston pressure.
301.Ve
302.PP
303Similarly, one can include an explanation in a plan line,
304emitted if the test file is skipped completely:
305.PP
306.Vb 1
307\& 1..0 # Skipped: WWW::Mechanize not installed
308.Ve
309.SH "OTHER LINES"
310.IX Header "OTHER LINES"
311.Sh "Bail out!"
312.IX Subsection "Bail out!"
313As an emergency measure a test script can decide that further tests
314are useless (e.g. missing dependencies) and testing should stop
315immediately. In that case the test script prints the magic words
316.PP
317.Vb 1
318\& Bail out!
319.Ve
320.PP
321to standard output. Any message after these words must be displayed
322by the interpreter as the reason why testing must be stopped, as
323in
324.PP
325.Vb 1
326\& Bail out! MySQL is not running.
327.Ve
328.Sh "Diagnostics"
329.IX Subsection "Diagnostics"
330Additional information may be put into the testing output on separate
331lines. Diagnostic lines should begin with a \f(CW\*(C`#\*(C'\fR, which the harness must
332ignore, at least as far as analyzing the test results. The harness is
333free, however, to display the diagnostics. Typically diagnostics are
334used to provide information about the environment in which test file is
335running, or to delineate a group of tests.
336.PP
337.Vb 9
338\& ...
339\& ok 18 - Closed database connection
340\& # End of database section.
341\& # This starts the network part of the test.
342\& # Daemon started on port 2112
343\& ok 19 - Opened socket
344\& ...
345\& ok 47 - Closed socket
346\& # End of network tests
347.Ve
348.Sh "Anything else"
349.IX Subsection "Anything else"
350Any output line that is not a plan, a test line or a diagnostic is
351incorrect. How a harness handles the incorrect line is undefined.
352Test::Harness silently ignores incorrect lines, but will become more
353stringent in the future.
354.SH "EXAMPLES"
355.IX Header "EXAMPLES"
356All names, places, and events depicted in any example are wholly
357fictitious and bear no resemblance to, connection with, or relation to any
358real entity. Any such similarity is purely coincidental, unintentional,
359and unintended.
360.Sh "Common with explanation"
361.IX Subsection "Common with explanation"
362The following \s-1TAP\s0 listing declares that six tests follow as well as
363provides handy feedback as to what the test is about to do. All six
364tests pass.
365.PP
366.Vb 11
367\& 1..6
368\& #
369\& # Create a new Board and Tile, then place
370\& # the Tile onto the board.
371\& #
372\& ok 1 - The object isa Board
373\& ok 2 - Board size is zero
374\& ok 3 - The object isa Tile
375\& ok 4 - Get possible places to put the Tile
376\& ok 5 - Placing the tile produces no error
377\& ok 6 - Board size is 1
378.Ve
379.Sh "Unknown amount and failures"
380.IX Subsection "Unknown amount and failures"
381This hypothetical test program ensures that a handful of servers are
382online and network\-accessible. Because it retrieves the hypothetical
383servers from a database, it doesn't know exactly how many servers it
384will need to ping. Thus, the test count is declared at the bottom after
385all the test points have run. Also, two of the tests fail.
386.PP
387.Vb 9
388\& ok 1 - retrieving servers from the database
389\& # need to ping 6 servers
390\& ok 2 - pinged diamond
391\& ok 3 - pinged ruby
392\& not ok 4 - pinged saphire
393\& ok 5 - pinged onyx
394\& not ok 6 - pinged quartz
395\& ok 7 - pinged gold
396\& 1..7
397.Ve
398.Sh "Giving up"
399.IX Subsection "Giving up"
400This listing reports that a pile of tests are going to be run. However,
401the first test fails, reportedly because a connection to the database
402could not be established. The program decided that continuing was
403pointless and exited.
404.PP
405.Vb 3
406\& 1..573
407\& not ok 1 - database handle
408\& Bail out! Couldn't connect to database.
409.Ve
410.Sh "Skipping a few"
411.IX Subsection "Skipping a few"
412The following listing plans on running 5 tests. However, our program
413decided to not run tests 2 thru 5 at all. To properly report this,
414the tests are marked as being skipped.
415.PP
416.Vb 7
417\& 1..5
418\& ok 1 - approved operating system
419\& # $^0 is solaris
420\& ok 2 - # SKIP no /sys directory
421\& ok 3 - # SKIP no /sys directory
422\& ok 4 - # SKIP no /sys directory
423\& ok 5 - # SKIP no /sys directory
424.Ve
425.Sh "Skipping everything"
426.IX Subsection "Skipping everything"
427This listing shows that the entire listing is a skip. No tests were run.
428.PP
429.Vb 1
430\& 1..0 # skip because English-to-French translator isn't installed
431.Ve
432.Sh "Got spare tuits?"
433.IX Subsection "Got spare tuits?"
434The following example reports that four tests are run and the last two
435tests failed. However, because the failing tests are marked as things
436to do later, they are considered successes. Thus, a harness should report
437this entire listing as a success.
438.PP
439.Vb 5
440\& 1..4
441\& ok 1 - Creating test program
442\& ok 2 - Test program runs, no error
443\& not ok 3 - infinite loop # TODO halting problem unsolved
444\& not ok 4 - infinite loop 2 # TODO halting problem unsolved
445.Ve
446.Sh "Creative liberties"
447.IX Subsection "Creative liberties"
448This listing shows an alternate output where the test numbers aren't
449provided. The test also reports the state of a ficticious board game in
450diagnostic form. Finally, the test count is reported at the end.
451.PP
452.Vb 23
453\& ok - created Board
454\& ok
455\& ok
456\& ok
457\& ok
458\& ok
459\& ok
460\& ok
461\& # +------+------+------+------+
462\& # | |16G | |05C |
463\& # | |G N C | |C C G |
464\& # | | G | | C +|
465\& # +------+------+------+------+
466\& # |10C |01G | |03C |
467\& # |R N G |G A G | |C C C |
468\& # | R | G | | C +|
469\& # +------+------+------+------+
470\& # | |01G |17C |00C |
471\& # | |G A G |G N R |R N R |
472\& # | | G | R | G |
473\& # +------+------+------+------+
474\& ok - board has 7 tiles + starter tile
475\& 1..9
476.Ve
477.SH "AUTHORS"
478.IX Header "AUTHORS"
479Andy Lester, based on the original Test::Harness documentation by Michael Schwern.
480.SH "ACKNOWLEDGEMENTS"
481.IX Header "ACKNOWLEDGEMENTS"
482Thanks to
483Pete Krawczyk,
484Paul Johnson,
485Ian Langworth
486and Nik Clayton
487for help and contributions on this document.
488.PP
489The basis for the \s-1TAP\s0 format was created by Larry Wall in the
490original test script for Perl 1. Tim Bunce and Andreas Koenig
491developed it further with their modifications to Test::Harness.
492.SH "COPYRIGHT"
493.IX Header "COPYRIGHT"
494Copyright 2003\-2005 by
495Michael G Schwern \f(CW\*(C`<schwern@pobox.com>\*(C'\fR,
496Andy Lester \f(CW\*(C`<andy@petdance.com>\*(C'\fR.
497.PP
498This program is free software; you can redistribute it and/or
499modify it under the same terms as Perl itself.
500.PP
501See <http://www.perl.com/perl/misc/Artistic.html>.