Add built local::lib
[catagits/Gitalist.git] / local-lib5 / man / man3 / TAP::Parser.3pm
1 .\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.3
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 "TAP::Parser 3"
132 .TH TAP::Parser 3 "2009-05-05" "perl v5.8.7" "User Contributed Perl Documentation"
133 .SH "NAME"
134 TAP::Parser \- Parse TAP output
135 .SH "VERSION"
136 .IX Header "VERSION"
137 Version 3.17
138 .SH "SYNOPSIS"
139 .IX Header "SYNOPSIS"
140 .Vb 1
141 \&    use TAP::Parser;
142 .Ve
143 .PP
144 .Vb 1
145 \&    my $parser = TAP::Parser\->new( { source => $source } );
146 .Ve
147 .PP
148 .Vb 3
149 \&    while ( my $result = $parser\->next ) {
150 \&        print $result\->as_string;
151 \&    }
152 .Ve
153 .SH "DESCRIPTION"
154 .IX Header "DESCRIPTION"
155 \&\f(CW\*(C`TAP::Parser\*(C'\fR is designed to produce a proper parse of \s-1TAP\s0 output. For
156 an example of how to run tests through this module, see the simple
157 harnesses \f(CW\*(C`examples/\*(C'\fR.
158 .PP
159 There's a wiki dedicated to the Test Anything Protocol:
160 .PP
161 <http://testanything.org>
162 .PP
163 It includes the TAP::Parser Cookbook:
164 .PP
165 <http://testanything.org/wiki/index.php/TAP::Parser_Cookbook>
166 .SH "METHODS"
167 .IX Header "METHODS"
168 .Sh "Class Methods"
169 .IX Subsection "Class Methods"
170 \fI\f(CI\*(C`new\*(C'\fI\fR
171 .IX Subsection "new"
172 .PP
173 .Vb 1
174 \& my $parser = TAP::Parser\->new(\e%args);
175 .Ve
176 .PP
177 Returns a new \f(CW\*(C`TAP::Parser\*(C'\fR object.
178 .PP
179 The arguments should be a hashref with \fIone\fR of the following keys:
180 .ie n .IP "* ""source""" 4
181 .el .IP "* \f(CWsource\fR" 4
182 .IX Item "source"
183 This is the preferred method of passing arguments to the constructor.  To
184 determine how to handle the source, the following steps are taken.
185 .Sp
186 If the source contains a newline, it's assumed to be a string of raw \s-1TAP\s0
187 output.
188 .Sp
189 If the source is a reference, it's assumed to be something to pass to
190 the TAP::Parser::Iterator::Stream constructor. This is used
191 internally and you should not use it.
192 .Sp
193 Otherwise, the parser does a \f(CW\*(C`\-e\*(C'\fR check to see if the source exists.  If so,
194 it attempts to execute the source and read the output as a stream.  This is by
195 far the preferred method of using the parser.
196 .Sp
197 .Vb 4
198 \& foreach my $file ( @test_files ) {
199 \&     my $parser = TAP::Parser\->new( { source => $file } );
200 \&     # do stuff with the parser
201 \& }
202 .Ve
203 .ie n .IP "* ""tap""" 4
204 .el .IP "* \f(CWtap\fR" 4
205 .IX Item "tap"
206 The value should be the complete \s-1TAP\s0 output.
207 .ie n .IP "* ""exec""" 4
208 .el .IP "* \f(CWexec\fR" 4
209 .IX Item "exec"
210 If passed an array reference, will attempt to create the iterator by
211 passing a TAP::Parser::Source object to
212 TAP::Parser::Iterator::Source, using the array reference strings as
213 the command arguments to IPC::Open3::open3:
214 .Sp
215 .Vb 1
216 \& exec => [ '/usr/bin/ruby', 't/my_test.rb' ]
217 .Ve
218 .Sp
219 Note that \f(CW\*(C`source\*(C'\fR and \f(CW\*(C`exec\*(C'\fR are mutually exclusive.
220 .PP
221 The following keys are optional.
222 .ie n .IP "* ""callback""" 4
223 .el .IP "* \f(CWcallback\fR" 4
224 .IX Item "callback"
225 If present, each callback corresponding to a given result type will be called
226 with the result as the argument if the \f(CW\*(C`run\*(C'\fR method is used:
227 .Sp
228 .Vb 7
229 \& my %callbacks = (
230 \&     test    => \e&test_callback,
231 \&     plan    => \e&plan_callback,
232 \&     comment => \e&comment_callback,
233 \&     bailout => \e&bailout_callback,
234 \&     unknown => \e&unknown_callback,
235 \& );
236 .Ve
237 .Sp
238 .Vb 11
239 \& my $aggregator = TAP::Parser::Aggregator\->new;
240 \& foreach my $file ( @test_files ) {
241 \&     my $parser = TAP::Parser\->new(
242 \&         {
243 \&             source    => $file,
244 \&             callbacks => \e%callbacks,
245 \&         }
246 \&     );
247 \&     $parser\->run;
248 \&     $aggregator\->add( $file, $parser );
249 \& }
250 .Ve
251 .ie n .IP "* ""switches""" 4
252 .el .IP "* \f(CWswitches\fR" 4
253 .IX Item "switches"
254 If using a Perl file as a source, optional switches may be passed which will
255 be used when invoking the perl executable.
256 .Sp
257 .Vb 4
258 \& my $parser = TAP::Parser\->new( {
259 \&     source   => $test_file,
260 \&     switches => '\-Ilib',
261 \& } );
262 .Ve
263 .ie n .IP "* ""test_args""" 4
264 .el .IP "* \f(CWtest_args\fR" 4
265 .IX Item "test_args"
266 Used in conjunction with the \f(CW\*(C`source\*(C'\fR option to supply a reference to
267 an \f(CW@ARGV\fR style array of arguments to pass to the test program.
268 .ie n .IP "* ""spool""" 4
269 .el .IP "* \f(CWspool\fR" 4
270 .IX Item "spool"
271 If passed a filehandle will write a copy of all parsed \s-1TAP\s0 to that handle.
272 .ie n .IP "* ""merge""" 4
273 .el .IP "* \f(CWmerge\fR" 4
274 .IX Item "merge"
275 If false, \s-1STDERR\s0 is not captured (though it is 'relayed' to keep it
276 somewhat synchronized with \s-1STDOUT\s0.)
277 .Sp
278 If true, \s-1STDERR\s0 and \s-1STDOUT\s0 are the same filehandle.  This may cause
279 breakage if \s-1STDERR\s0 contains anything resembling \s-1TAP\s0 format, but does
280 allow exact synchronization.
281 .Sp
282 Subtleties of this behavior may be platform-dependent and may change in
283 the future.
284 .ie n .IP "* ""source_class""" 4
285 .el .IP "* \f(CWsource_class\fR" 4
286 .IX Item "source_class"
287 This option was introduced to let you easily customize which \fIsource\fR class
288 the parser should use.  It defaults to TAP::Parser::Source.
289 .Sp
290 See also \*(L"make_source\*(R".
291 .ie n .IP "* ""perl_source_class""" 4
292 .el .IP "* \f(CWperl_source_class\fR" 4
293 .IX Item "perl_source_class"
294 This option was introduced to let you easily customize which \fIperl source\fR
295 class the parser should use.  It defaults to TAP::Parser::Source::Perl.
296 .Sp
297 See also \*(L"make_perl_source\*(R".
298 .ie n .IP "* ""grammar_class""" 4
299 .el .IP "* \f(CWgrammar_class\fR" 4
300 .IX Item "grammar_class"
301 This option was introduced to let you easily customize which \fIgrammar\fR class
302 the parser should use.  It defaults to TAP::Parser::Grammar.
303 .Sp
304 See also \*(L"make_grammar\*(R".
305 .ie n .IP "* ""iterator_factory_class""" 4
306 .el .IP "* \f(CWiterator_factory_class\fR" 4
307 .IX Item "iterator_factory_class"
308 This option was introduced to let you easily customize which \fIiterator\fR
309 factory class the parser should use.  It defaults to
310 TAP::Parser::IteratorFactory.
311 .Sp
312 See also \*(L"make_iterator\*(R".
313 .ie n .IP "* ""result_factory_class""" 4
314 .el .IP "* \f(CWresult_factory_class\fR" 4
315 .IX Item "result_factory_class"
316 This option was introduced to let you easily customize which \fIresult\fR
317 factory class the parser should use.  It defaults to
318 TAP::Parser::ResultFactory.
319 .Sp
320 See also \*(L"make_result\*(R".
321 .Sh "Instance Methods"
322 .IX Subsection "Instance Methods"
323 \fI\f(CI\*(C`next\*(C'\fI\fR
324 .IX Subsection "next"
325 .PP
326 .Vb 4
327 \&  my $parser = TAP::Parser\->new( { source => $file } );
328 \&  while ( my $result = $parser\->next ) {
329 \&      print $result\->as_string, "\en";
330 \&  }
331 .Ve
332 .PP
333 This method returns the results of the parsing, one result at a time.  Note
334 that it is destructive.  You can't rewind and examine previous results.
335 .PP
336 If callbacks are used, they will be issued before this call returns.
337 .PP
338 Each result returned is a subclass of TAP::Parser::Result.  See that
339 module and related classes for more information on how to use them.
340 .PP
341 \fI\f(CI\*(C`run\*(C'\fI\fR
342 .IX Subsection "run"
343 .PP
344 .Vb 1
345 \&  $parser\->run;
346 .Ve
347 .PP
348 This method merely runs the parser and parses all of the \s-1TAP\s0.
349 .PP
350 \fI\f(CI\*(C`make_source\*(C'\fI\fR
351 .IX Subsection "make_source"
352 .PP
353 Make a new TAP::Parser::Source object and return it.  Passes through any
354 arguments given.
355 .PP
356 The \f(CW\*(C`source_class\*(C'\fR can be customized, as described in \*(L"new\*(R".
357 .PP
358 \fI\f(CI\*(C`make_perl_source\*(C'\fI\fR
359 .IX Subsection "make_perl_source"
360 .PP
361 Make a new TAP::Parser::Source::Perl object and return it.  Passes through
362 any arguments given.
363 .PP
364 The \f(CW\*(C`perl_source_class\*(C'\fR can be customized, as described in \*(L"new\*(R".
365 .PP
366 \fI\f(CI\*(C`make_grammar\*(C'\fI\fR
367 .IX Subsection "make_grammar"
368 .PP
369 Make a new TAP::Parser::Grammar object and return it.  Passes through any
370 arguments given.
371 .PP
372 The \f(CW\*(C`grammar_class\*(C'\fR can be customized, as described in \*(L"new\*(R".
373 .PP
374 \fI\f(CI\*(C`make_iterator\*(C'\fI\fR
375 .IX Subsection "make_iterator"
376 .PP
377 Make a new TAP::Parser::Iterator object using the parser's
378 TAP::Parser::IteratorFactory, and return it.  Passes through any arguments
379 given.
380 .PP
381 The \f(CW\*(C`iterator_factory_class\*(C'\fR can be customized, as described in \*(L"new\*(R".
382 .PP
383 \fI\f(CI\*(C`make_result\*(C'\fI\fR
384 .IX Subsection "make_result"
385 .PP
386 Make a new TAP::Parser::Result object using the parser's
387 TAP::Parser::ResultFactory, and return it.  Passes through any arguments
388 given.
389 .PP
390 The \f(CW\*(C`result_factory_class\*(C'\fR can be customized, as described in \*(L"new\*(R".
391 .SH "INDIVIDUAL RESULTS"
392 .IX Header "INDIVIDUAL RESULTS"
393 If you've read this far in the docs, you've seen this:
394 .PP
395 .Vb 3
396 \&    while ( my $result = $parser\->next ) {
397 \&        print $result\->as_string;
398 \&    }
399 .Ve
400 .PP
401 Each result returned is a TAP::Parser::Result subclass, referred to as
402 \&\fIresult types\fR.
403 .Sh "Result types"
404 .IX Subsection "Result types"
405 Basically, you fetch individual results from the \s-1TAP\s0.  The six types, with
406 examples of each, are as follows:
407 .IP "* Version" 4
408 .IX Item "Version"
409 .Vb 1
410 \& TAP version 12
411 .Ve
412 .IP "* Plan" 4
413 .IX Item "Plan"
414 .Vb 1
415 \& 1..42
416 .Ve
417 .IP "* Pragma" 4
418 .IX Item "Pragma"
419 .Vb 1
420 \& pragma +strict
421 .Ve
422 .IP "* Test" 4
423 .IX Item "Test"
424 .Vb 1
425 \& ok 3 \- We should start with some foobar!
426 .Ve
427 .IP "* Comment" 4
428 .IX Item "Comment"
429 .Vb 1
430 \& # Hope we don't use up the foobar.
431 .Ve
432 .IP "* Bailout" 4
433 .IX Item "Bailout"
434 .Vb 1
435 \& Bail out!  We ran out of foobar!
436 .Ve
437 .IP "* Unknown" 4
438 .IX Item "Unknown"
439 .Vb 1
440 \& ... yo, this ain't TAP! ...
441 .Ve
442 .PP
443 Each result fetched is a result object of a different type.  There are common
444 methods to each result object and different types may have methods unique to
445 their type.  Sometimes a type method may be overridden in a subclass, but its
446 use is guaranteed to be identical.
447 .Sh "Common type methods"
448 .IX Subsection "Common type methods"
449 \fI\f(CI\*(C`type\*(C'\fI\fR
450 .IX Subsection "type"
451 .PP
452 Returns the type of result, such as \f(CW\*(C`comment\*(C'\fR or \f(CW\*(C`test\*(C'\fR.
453 .PP
454 \fI\f(CI\*(C`as_string\*(C'\fI\fR
455 .IX Subsection "as_string"
456 .PP
457 Prints a string representation of the token.  This might not be the exact
458 output, however.  Tests will have test numbers added if not present, \s-1TODO\s0 and
459 \&\s-1SKIP\s0 directives will be capitalized and, in general, things will be cleaned
460 up.  If you need the original text for the token, see the \f(CW\*(C`raw\*(C'\fR method.
461 .PP
462 \fI\f(CI\*(C`raw\*(C'\fI\fR
463 .IX Subsection "raw"
464 .PP
465 Returns the original line of text which was parsed.
466 .PP
467 \fI\f(CI\*(C`is_plan\*(C'\fI\fR
468 .IX Subsection "is_plan"
469 .PP
470 Indicates whether or not this is the test plan line.
471 .PP
472 \fI\f(CI\*(C`is_test\*(C'\fI\fR
473 .IX Subsection "is_test"
474 .PP
475 Indicates whether or not this is a test line.
476 .PP
477 \fI\f(CI\*(C`is_comment\*(C'\fI\fR
478 .IX Subsection "is_comment"
479 .PP
480 Indicates whether or not this is a comment. Comments will generally only
481 appear in the \s-1TAP\s0 stream if \s-1STDERR\s0 is merged to \s-1STDOUT\s0. See the
482 \&\f(CW\*(C`merge\*(C'\fR option.
483 .PP
484 \fI\f(CI\*(C`is_bailout\*(C'\fI\fR
485 .IX Subsection "is_bailout"
486 .PP
487 Indicates whether or not this is bailout line.
488 .PP
489 \fI\f(CI\*(C`is_yaml\*(C'\fI\fR
490 .IX Subsection "is_yaml"
491 .PP
492 Indicates whether or not the current item is a \s-1YAML\s0 block.
493 .PP
494 \fI\f(CI\*(C`is_unknown\*(C'\fI\fR
495 .IX Subsection "is_unknown"
496 .PP
497 Indicates whether or not the current line could be parsed.
498 .PP
499 \fI\f(CI\*(C`is_ok\*(C'\fI\fR
500 .IX Subsection "is_ok"
501 .PP
502 .Vb 1
503 \&  if ( $result\->is_ok ) { ... }
504 .Ve
505 .PP
506 Reports whether or not a given result has passed.  Anything which is \fBnot\fR a
507 test result returns true.  This is merely provided as a convenient shortcut
508 which allows you to do this:
509 .PP
510 .Vb 5
511 \& my $parser = TAP::Parser\->new( { source => $source } );
512 \& while ( my $result = $parser\->next ) {
513 \&     # only print failing results
514 \&     print $result\->as_string unless $result\->is_ok;
515 \& }
516 .Ve
517 .ie n .Sh """plan"" methods"
518 .el .Sh "\f(CWplan\fP methods"
519 .IX Subsection "plan methods"
520 .Vb 1
521 \& if ( $result\->is_plan ) { ... }
522 .Ve
523 .PP
524 If the above evaluates as true, the following methods will be available on the
525 \&\f(CW$result\fR object.
526 .PP
527 \fI\f(CI\*(C`plan\*(C'\fI\fR
528 .IX Subsection "plan"
529 .PP
530 .Vb 3
531 \&  if ( $result\->is_plan ) {
532 \&     print $result\->plan;
533 \&  }
534 .Ve
535 .PP
536 This is merely a synonym for \f(CW\*(C`as_string\*(C'\fR.
537 .PP
538 \fI\f(CI\*(C`directive\*(C'\fI\fR
539 .IX Subsection "directive"
540 .PP
541 .Vb 1
542 \& my $directive = $result\->directive;
543 .Ve
544 .PP
545 If a \s-1SKIP\s0 directive is included with the plan, this method will return it.
546 .PP
547 .Vb 1
548 \& 1..0 # SKIP: why bother?
549 .Ve
550 .PP
551 \fI\f(CI\*(C`explanation\*(C'\fI\fR
552 .IX Subsection "explanation"
553 .PP
554 .Vb 1
555 \& my $explanation = $result\->explanation;
556 .Ve
557 .PP
558 If a \s-1SKIP\s0 directive was included with the plan, this method will return the
559 explanation, if any.
560 .ie n .Sh """pragma"" methods"
561 .el .Sh "\f(CWpragma\fP methods"
562 .IX Subsection "pragma methods"
563 .Vb 1
564 \& if ( $result\->is_pragma ) { ... }
565 .Ve
566 .PP
567 If the above evaluates as true, the following methods will be available on the
568 \&\f(CW$result\fR object.
569 .PP
570 \fI\f(CI\*(C`pragmas\*(C'\fI\fR
571 .IX Subsection "pragmas"
572 .PP
573 Returns a list of pragmas each of which is a + or \- followed by the
574 pragma name.
575 .ie n .Sh """commment"" methods"
576 .el .Sh "\f(CWcommment\fP methods"
577 .IX Subsection "commment methods"
578 .Vb 1
579 \& if ( $result\->is_comment ) { ... }
580 .Ve
581 .PP
582 If the above evaluates as true, the following methods will be available on the
583 \&\f(CW$result\fR object.
584 .PP
585 \fI\f(CI\*(C`comment\*(C'\fI\fR
586 .IX Subsection "comment"
587 .PP
588 .Vb 4
589 \&  if ( $result\->is_comment ) {
590 \&      my $comment = $result\->comment;
591 \&      print "I have something to say:  $comment";
592 \&  }
593 .Ve
594 .ie n .Sh """bailout"" methods"
595 .el .Sh "\f(CWbailout\fP methods"
596 .IX Subsection "bailout methods"
597 .Vb 1
598 \& if ( $result\->is_bailout ) { ... }
599 .Ve
600 .PP
601 If the above evaluates as true, the following methods will be available on the
602 \&\f(CW$result\fR object.
603 .PP
604 \fI\f(CI\*(C`explanation\*(C'\fI\fR
605 .IX Subsection "explanation"
606 .PP
607 .Vb 4
608 \&  if ( $result\->is_bailout ) {
609 \&      my $explanation = $result\->explanation;
610 \&      print "We bailed out because ($explanation)";
611 \&  }
612 .Ve
613 .PP
614 If, and only if, a token is a bailout token, you can get an \*(L"explanation\*(R" via
615 this method.  The explanation is the text after the mystical \*(L"Bail out!\*(R" words
616 which appear in the tap output.
617 .ie n .Sh """unknown"" methods"
618 .el .Sh "\f(CWunknown\fP methods"
619 .IX Subsection "unknown methods"
620 .Vb 1
621 \& if ( $result\->is_unknown ) { ... }
622 .Ve
623 .PP
624 There are no unique methods for unknown results.
625 .ie n .Sh """test"" methods"
626 .el .Sh "\f(CWtest\fP methods"
627 .IX Subsection "test methods"
628 .Vb 1
629 \& if ( $result\->is_test ) { ... }
630 .Ve
631 .PP
632 If the above evaluates as true, the following methods will be available on the
633 \&\f(CW$result\fR object.
634 .PP
635 \fI\f(CI\*(C`ok\*(C'\fI\fR
636 .IX Subsection "ok"
637 .PP
638 .Vb 1
639 \&  my $ok = $result\->ok;
640 .Ve
641 .PP
642 Returns the literal text of the \f(CW\*(C`ok\*(C'\fR or \f(CW\*(C`not ok\*(C'\fR status.
643 .PP
644 \fI\f(CI\*(C`number\*(C'\fI\fR
645 .IX Subsection "number"
646 .PP
647 .Vb 1
648 \&  my $test_number = $result\->number;
649 .Ve
650 .PP
651 Returns the number of the test, even if the original \s-1TAP\s0 output did not supply
652 that number.
653 .PP
654 \fI\f(CI\*(C`description\*(C'\fI\fR
655 .IX Subsection "description"
656 .PP
657 .Vb 1
658 \&  my $description = $result\->description;
659 .Ve
660 .PP
661 Returns the description of the test, if any.  This is the portion after the
662 test number but before the directive.
663 .PP
664 \fI\f(CI\*(C`directive\*(C'\fI\fR
665 .IX Subsection "directive"
666 .PP
667 .Vb 1
668 \&  my $directive = $result\->directive;
669 .Ve
670 .PP
671 Returns either \f(CW\*(C`TODO\*(C'\fR or \f(CW\*(C`SKIP\*(C'\fR if either directive was present for a test
672 line.
673 .PP
674 \fI\f(CI\*(C`explanation\*(C'\fI\fR
675 .IX Subsection "explanation"
676 .PP
677 .Vb 1
678 \&  my $explanation = $result\->explanation;
679 .Ve
680 .PP
681 If a test had either a \f(CW\*(C`TODO\*(C'\fR or \f(CW\*(C`SKIP\*(C'\fR directive, this method will return
682 the accompanying explantion, if present.
683 .PP
684 .Vb 1
685 \&  not ok 17 \- 'Pigs can fly' # TODO not enough acid
686 .Ve
687 .PP
688 For the above line, the explanation is \fInot enough acid\fR.
689 .PP
690 \fI\f(CI\*(C`is_ok\*(C'\fI\fR
691 .IX Subsection "is_ok"
692 .PP
693 .Vb 1
694 \&  if ( $result\->is_ok ) { ... }
695 .Ve
696 .PP
697 Returns a boolean value indicating whether or not the test passed.  Remember
698 that for \s-1TODO\s0 tests, the test always passes.
699 .PP
700 \&\fBNote:\fR  this was formerly \f(CW\*(C`passed\*(C'\fR.  The latter method is deprecated and
701 will issue a warning.
702 .PP
703 \fI\f(CI\*(C`is_actual_ok\*(C'\fI\fR
704 .IX Subsection "is_actual_ok"
705 .PP
706 .Vb 1
707 \&  if ( $result\->is_actual_ok ) { ... }
708 .Ve
709 .PP
710 Returns a boolean value indicating whether or not the test passed, regardless
711 of its \s-1TODO\s0 status.
712 .PP
713 \&\fBNote:\fR  this was formerly \f(CW\*(C`actual_passed\*(C'\fR.  The latter method is deprecated
714 and will issue a warning.
715 .PP
716 \fI\f(CI\*(C`is_unplanned\*(C'\fI\fR
717 .IX Subsection "is_unplanned"
718 .PP
719 .Vb 1
720 \&  if ( $test\->is_unplanned ) { ... }
721 .Ve
722 .PP
723 If a test number is greater than the number of planned tests, this method will
724 return true.  Unplanned tests will \fIalways\fR return false for \f(CW\*(C`is_ok\*(C'\fR,
725 regardless of whether or not the test \f(CW\*(C`has_todo\*(C'\fR (see
726 TAP::Parser::Result::Test for more information about this).
727 .PP
728 \fI\f(CI\*(C`has_skip\*(C'\fI\fR
729 .IX Subsection "has_skip"
730 .PP
731 .Vb 1
732 \&  if ( $result\->has_skip ) { ... }
733 .Ve
734 .PP
735 Returns a boolean value indicating whether or not this test had a \s-1SKIP\s0
736 directive.
737 .PP
738 \fI\f(CI\*(C`has_todo\*(C'\fI\fR
739 .IX Subsection "has_todo"
740 .PP
741 .Vb 1
742 \&  if ( $result\->has_todo ) { ... }
743 .Ve
744 .PP
745 Returns a boolean value indicating whether or not this test had a \s-1TODO\s0
746 directive.
747 .PP
748 Note that \s-1TODO\s0 tests \fIalways\fR pass.  If you need to know whether or not
749 they really passed, check the \f(CW\*(C`is_actual_ok\*(C'\fR method.
750 .PP
751 \fI\f(CI\*(C`in_todo\*(C'\fI\fR
752 .IX Subsection "in_todo"
753 .PP
754 .Vb 1
755 \&  if ( $parser\->in_todo ) { ... }
756 .Ve
757 .PP
758 True while the most recent result was a \s-1TODO\s0. Becomes true before the
759 \&\s-1TODO\s0 result is returned and stays true until just before the next non\-
760 \&\s-1TODO\s0 test is returned.
761 .SH "TOTAL RESULTS"
762 .IX Header "TOTAL RESULTS"
763 After parsing the \s-1TAP\s0, there are many methods available to let you dig through
764 the results and determine what is meaningful to you.
765 .Sh "Individual Results"
766 .IX Subsection "Individual Results"
767 These results refer to individual tests which are run.
768 .PP
769 \fI\f(CI\*(C`passed\*(C'\fI\fR
770 .IX Subsection "passed"
771 .PP
772 .Vb 2
773 \& my @passed = $parser\->passed; # the test numbers which passed
774 \& my $passed = $parser\->passed; # the number of tests which passed
775 .Ve
776 .PP
777 This method lets you know which (or how many) tests passed.  If a test failed
778 but had a \s-1TODO\s0 directive, it will be counted as a passed test.
779 .PP
780 \fI\f(CI\*(C`failed\*(C'\fI\fR
781 .IX Subsection "failed"
782 .PP
783 .Vb 2
784 \& my @failed = $parser\->failed; # the test numbers which failed
785 \& my $failed = $parser\->failed; # the number of tests which failed
786 .Ve
787 .PP
788 This method lets you know which (or how many) tests failed.  If a test passed
789 but had a \s-1TODO\s0 directive, it will \fB\s-1NOT\s0\fR be counted as a failed test.
790 .PP
791 \fI\f(CI\*(C`actual_passed\*(C'\fI\fR
792 .IX Subsection "actual_passed"
793 .PP
794 .Vb 2
795 \& # the test numbers which actually passed
796 \& my @actual_passed = $parser\->actual_passed;
797 .Ve
798 .PP
799 .Vb 2
800 \& # the number of tests which actually passed
801 \& my $actual_passed = $parser\->actual_passed;
802 .Ve
803 .PP
804 This method lets you know which (or how many) tests actually passed,
805 regardless of whether or not a \s-1TODO\s0 directive was found.
806 .PP
807 \fI\f(CI\*(C`actual_ok\*(C'\fI\fR
808 .IX Subsection "actual_ok"
809 .PP
810 This method is a synonym for \f(CW\*(C`actual_passed\*(C'\fR.
811 .PP
812 \fI\f(CI\*(C`actual_failed\*(C'\fI\fR
813 .IX Subsection "actual_failed"
814 .PP
815 .Vb 2
816 \& # the test numbers which actually failed
817 \& my @actual_failed = $parser\->actual_failed;
818 .Ve
819 .PP
820 .Vb 2
821 \& # the number of tests which actually failed
822 \& my $actual_failed = $parser\->actual_failed;
823 .Ve
824 .PP
825 This method lets you know which (or how many) tests actually failed,
826 regardless of whether or not a \s-1TODO\s0 directive was found.
827 .PP
828 \fI\f(CI\*(C`todo\*(C'\fI\fR
829 .IX Subsection "todo"
830 .PP
831 .Vb 2
832 \& my @todo = $parser\->todo; # the test numbers with todo directives
833 \& my $todo = $parser\->todo; # the number of tests with todo directives
834 .Ve
835 .PP
836 This method lets you know which (or how many) tests had \s-1TODO\s0 directives.
837 .PP
838 \fI\f(CI\*(C`todo_passed\*(C'\fI\fR
839 .IX Subsection "todo_passed"
840 .PP
841 .Vb 2
842 \& # the test numbers which unexpectedly succeeded
843 \& my @todo_passed = $parser\->todo_passed;
844 .Ve
845 .PP
846 .Vb 2
847 \& # the number of tests which unexpectedly succeeded
848 \& my $todo_passed = $parser\->todo_passed;
849 .Ve
850 .PP
851 This method lets you know which (or how many) tests actually passed but were
852 declared as \*(L"\s-1TODO\s0\*(R" tests.
853 .PP
854 \fI\f(CI\*(C`todo_failed\*(C'\fI\fR
855 .IX Subsection "todo_failed"
856 .PP
857 .Vb 1
858 \&  # deprecated in favor of 'todo_passed'.  This method was horribly misnamed.
859 .Ve
860 .PP
861 This was a badly misnamed method.  It indicates which \s-1TODO\s0 tests unexpectedly
862 succeeded.  Will now issue a warning and call \f(CW\*(C`todo_passed\*(C'\fR.
863 .PP
864 \fI\f(CI\*(C`skipped\*(C'\fI\fR
865 .IX Subsection "skipped"
866 .PP
867 .Vb 2
868 \& my @skipped = $parser\->skipped; # the test numbers with SKIP directives
869 \& my $skipped = $parser\->skipped; # the number of tests with SKIP directives
870 .Ve
871 .PP
872 This method lets you know which (or how many) tests had \s-1SKIP\s0 directives.
873 .Sh "Pragmas"
874 .IX Subsection "Pragmas"
875 \fI\f(CI\*(C`pragma\*(C'\fI\fR
876 .IX Subsection "pragma"
877 .PP
878 Get or set a pragma. To get the state of a pragma:
879 .PP
880 .Vb 3
881 \&  if ( $p\->pragma('strict') ) {
882 \&      # be strict
883 \&  }
884 .Ve
885 .PP
886 To set the state of a pragma:
887 .PP
888 .Vb 1
889 \&  $p\->pragma('strict', 1); # enable strict mode
890 .Ve
891 .PP
892 \fI\f(CI\*(C`pragmas\*(C'\fI\fR
893 .IX Subsection "pragmas"
894 .PP
895 Get a list of all the currently enabled pragmas:
896 .PP
897 .Vb 1
898 \&  my @pragmas_enabled = $p\->pragmas;
899 .Ve
900 .Sh "Summary Results"
901 .IX Subsection "Summary Results"
902 These results are \*(L"meta\*(R" information about the total results of an individual
903 test program.
904 .PP
905 \fI\f(CI\*(C`plan\*(C'\fI\fR
906 .IX Subsection "plan"
907 .PP
908 .Vb 1
909 \& my $plan = $parser\->plan;
910 .Ve
911 .PP
912 Returns the test plan, if found.
913 .PP
914 \fI\f(CI\*(C`good_plan\*(C'\fI\fR
915 .IX Subsection "good_plan"
916 .PP
917 Deprecated.  Use \f(CW\*(C`is_good_plan\*(C'\fR instead.
918 .PP
919 \fI\f(CI\*(C`is_good_plan\*(C'\fI\fR
920 .IX Subsection "is_good_plan"
921 .PP
922 .Vb 1
923 \&  if ( $parser\->is_good_plan ) { ... }
924 .Ve
925 .PP
926 Returns a boolean value indicating whether or not the number of tests planned
927 matches the number of tests run.
928 .PP
929 \&\fBNote:\fR  this was formerly \f(CW\*(C`good_plan\*(C'\fR.  The latter method is deprecated and
930 will issue a warning.
931 .PP
932 And since we're on that subject ...
933 .PP
934 \fI\f(CI\*(C`tests_planned\*(C'\fI\fR
935 .IX Subsection "tests_planned"
936 .PP
937 .Vb 1
938 \&  print $parser\->tests_planned;
939 .Ve
940 .PP
941 Returns the number of tests planned, according to the plan.  For example, a
942 plan of '1..17' will mean that 17 tests were planned.
943 .PP
944 \fI\f(CI\*(C`tests_run\*(C'\fI\fR
945 .IX Subsection "tests_run"
946 .PP
947 .Vb 1
948 \&  print $parser\->tests_run;
949 .Ve
950 .PP
951 Returns the number of tests which actually were run.  Hopefully this will
952 match the number of \f(CW\*(C`$parser\->tests_planned\*(C'\fR.
953 .PP
954 \fI\f(CI\*(C`skip_all\*(C'\fI\fR
955 .IX Subsection "skip_all"
956 .PP
957 Returns a true value (actually the reason for skipping) if all tests
958 were skipped.
959 .PP
960 \fI\f(CI\*(C`start_time\*(C'\fI\fR
961 .IX Subsection "start_time"
962 .PP
963 Returns the time when the Parser was created.
964 .PP
965 \fI\f(CI\*(C`end_time\*(C'\fI\fR
966 .IX Subsection "end_time"
967 .PP
968 Returns the time when the end of \s-1TAP\s0 input was seen.
969 .PP
970 \fI\f(CI\*(C`has_problems\*(C'\fI\fR
971 .IX Subsection "has_problems"
972 .PP
973 .Vb 3
974 \&  if ( $parser\->has_problems ) {
975 \&      ...
976 \&  }
977 .Ve
978 .PP
979 This is a 'catch\-all' method which returns true if any tests have currently
980 failed, any \s-1TODO\s0 tests unexpectedly succeeded, or any parse errors occurred.
981 .PP
982 \fI\f(CI\*(C`version\*(C'\fI\fR
983 .IX Subsection "version"
984 .PP
985 .Vb 1
986 \&  $parser\->version;
987 .Ve
988 .PP
989 Once the parser is done, this will return the version number for the
990 parsed \s-1TAP\s0. Version numbers were introduced with \s-1TAP\s0 version 13 so if no
991 version number is found version 12 is assumed.
992 .PP
993 \fI\f(CI\*(C`exit\*(C'\fI\fR
994 .IX Subsection "exit"
995 .PP
996 .Vb 1
997 \&  $parser\->exit;
998 .Ve
999 .PP
1000 Once the parser is done, this will return the exit status.  If the parser ran
1001 an executable, it returns the exit status of the executable.
1002 .PP
1003 \fI\f(CI\*(C`wait\*(C'\fI\fR
1004 .IX Subsection "wait"
1005 .PP
1006 .Vb 1
1007 \&  $parser\->wait;
1008 .Ve
1009 .PP
1010 Once the parser is done, this will return the wait status.  If the parser ran
1011 an executable, it returns the wait status of the executable.  Otherwise, this
1012 mererely returns the \f(CW\*(C`exit\*(C'\fR status.
1013 .ie n .Sh """ignore_exit"""
1014 .el .Sh "\f(CWignore_exit\fP"
1015 .IX Subsection "ignore_exit"
1016 .Vb 1
1017 \&  $parser\->ignore_exit(1);
1018 .Ve
1019 .PP
1020 Tell the parser to ignore the exit status from the test when determining
1021 whether the test passed. Normally tests with non-zero exit status are
1022 considered to have failed even if all individual tests passed. In cases
1023 where it is not possible to control the exit value of the test script
1024 use this option to ignore it.
1025 .PP
1026 \fI\f(CI\*(C`parse_errors\*(C'\fI\fR
1027 .IX Subsection "parse_errors"
1028 .PP
1029 .Vb 2
1030 \& my @errors = $parser\->parse_errors; # the parser errors
1031 \& my $errors = $parser\->parse_errors; # the number of parser_errors
1032 .Ve
1033 .PP
1034 Fortunately, all \s-1TAP\s0 output is perfect.  In the event that it is not, this
1035 method will return parser errors.  Note that a junk line which the parser does
1036 not recognize is \f(CW\*(C`not\*(C'\fR an error.  This allows this parser to handle future
1037 versions of \s-1TAP\s0.  The following are all \s-1TAP\s0 errors reported by the parser:
1038 .IP "* Misplaced plan" 4
1039 .IX Item "Misplaced plan"
1040 The plan (for example, '1..5'), must only come at the beginning or end of the
1041 \&\s-1TAP\s0 output.
1042 .IP "* No plan" 4
1043 .IX Item "No plan"
1044 Gotta have a plan!
1045 .IP "* More than one plan" 4
1046 .IX Item "More than one plan"
1047 .Vb 5
1048 \& 1..3
1049 \& ok 1 \- input file opened
1050 \& not ok 2 \- first line of the input valid # todo some data
1051 \& ok 3 read the rest of the file
1052 \& 1..3
1053 .Ve
1054 .Sp
1055 Right.  Very funny.  Don't do that.
1056 .IP "* Test numbers out of sequence" 4
1057 .IX Item "Test numbers out of sequence"
1058 .Vb 4
1059 \& 1..3
1060 \& ok 1 \- input file opened
1061 \& not ok 2 \- first line of the input valid # todo some data
1062 \& ok 2 read the rest of the file
1063 .Ve
1064 .Sp
1065 That last test line above should have the number '3' instead of '2'.
1066 .Sp
1067 Note that it's perfectly acceptable for some lines to have test numbers and
1068 others to not have them.  However, when a test number is found, it must be in
1069 sequence.  The following is also an error:
1070 .Sp
1071 .Vb 4
1072 \& 1..3
1073 \& ok 1 \- input file opened
1074 \& not ok \- first line of the input valid # todo some data
1075 \& ok 2 read the rest of the file
1076 .Ve
1077 .Sp
1078 But this is not:
1079 .Sp
1080 .Vb 4
1081 \& 1..3
1082 \& ok  \- input file opened
1083 \& not ok \- first line of the input valid # todo some data
1084 \& ok 3 read the rest of the file
1085 .Ve
1086 .PP
1087 \fI\f(CI\*(C`get_select_handles\*(C'\fI\fR
1088 .IX Subsection "get_select_handles"
1089 .PP
1090 Get an a list of file handles which can be passed to \f(CW\*(C`select\*(C'\fR to
1091 determine the readiness of this parser.
1092 .PP
1093 \fI\f(CI\*(C`delete_spool\*(C'\fI\fR
1094 .IX Subsection "delete_spool"
1095 .PP
1096 Delete and return the spool.
1097 .PP
1098 .Vb 1
1099 \&  my $fh = $parser\->delete_spool;
1100 .Ve
1101 .SH "CALLBACKS"
1102 .IX Header "CALLBACKS"
1103 As mentioned earlier, a \*(L"callback\*(R" key may be added to the
1104 \&\f(CW\*(C`TAP::Parser\*(C'\fR constructor. If present, each callback corresponding to a
1105 given result type will be called with the result as the argument if the
1106 \&\f(CW\*(C`run\*(C'\fR method is used. The callback is expected to be a subroutine
1107 reference (or anonymous subroutine) which is invoked with the parser
1108 result as its argument.
1109 .PP
1110 .Vb 7
1111 \& my %callbacks = (
1112 \&     test    => \e&test_callback,
1113 \&     plan    => \e&plan_callback,
1114 \&     comment => \e&comment_callback,
1115 \&     bailout => \e&bailout_callback,
1116 \&     unknown => \e&unknown_callback,
1117 \& );
1118 .Ve
1119 .PP
1120 .Vb 11
1121 \& my $aggregator = TAP::Parser::Aggregator\->new;
1122 \& foreach my $file ( @test_files ) {
1123 \&     my $parser = TAP::Parser\->new(
1124 \&         {
1125 \&             source    => $file,
1126 \&             callbacks => \e%callbacks,
1127 \&         }
1128 \&     );
1129 \&     $parser\->run;
1130 \&     $aggregator\->add( $file, $parser );
1131 \& }
1132 .Ve
1133 .PP
1134 Callbacks may also be added like this:
1135 .PP
1136 .Vb 2
1137 \& $parser\->callback( test => \e&test_callback );
1138 \& $parser\->callback( plan => \e&plan_callback );
1139 .Ve
1140 .PP
1141 The following keys allowed for callbacks. These keys are case\-sensitive.
1142 .ie n .IP "* ""test""" 4
1143 .el .IP "* \f(CWtest\fR" 4
1144 .IX Item "test"
1145 Invoked if \f(CW\*(C`$result\->is_test\*(C'\fR returns true.
1146 .ie n .IP "* ""version""" 4
1147 .el .IP "* \f(CWversion\fR" 4
1148 .IX Item "version"
1149 Invoked if \f(CW\*(C`$result\->is_version\*(C'\fR returns true.
1150 .ie n .IP "* ""plan""" 4
1151 .el .IP "* \f(CWplan\fR" 4
1152 .IX Item "plan"
1153 Invoked if \f(CW\*(C`$result\->is_plan\*(C'\fR returns true.
1154 .ie n .IP "* ""comment""" 4
1155 .el .IP "* \f(CWcomment\fR" 4
1156 .IX Item "comment"
1157 Invoked if \f(CW\*(C`$result\->is_comment\*(C'\fR returns true.
1158 .ie n .IP "* ""bailout""" 4
1159 .el .IP "* \f(CWbailout\fR" 4
1160 .IX Item "bailout"
1161 Invoked if \f(CW\*(C`$result\->is_unknown\*(C'\fR returns true.
1162 .ie n .IP "* ""yaml""" 4
1163 .el .IP "* \f(CWyaml\fR" 4
1164 .IX Item "yaml"
1165 Invoked if \f(CW\*(C`$result\->is_yaml\*(C'\fR returns true.
1166 .ie n .IP "* ""unknown""" 4
1167 .el .IP "* \f(CWunknown\fR" 4
1168 .IX Item "unknown"
1169 Invoked if \f(CW\*(C`$result\->is_unknown\*(C'\fR returns true.
1170 .ie n .IP "* ""ELSE""" 4
1171 .el .IP "* \f(CWELSE\fR" 4
1172 .IX Item "ELSE"
1173 If a result does not have a callback defined for it, this callback will
1174 be invoked. Thus, if all of the previous result types are specified as
1175 callbacks, this callback will \fInever\fR be invoked.
1176 .ie n .IP "* ""ALL""" 4
1177 .el .IP "* \f(CWALL\fR" 4
1178 .IX Item "ALL"
1179 This callback will always be invoked and this will happen for each
1180 result after one of the above callbacks is invoked.  For example, if
1181 Term::ANSIColor is loaded, you could use the following to color your
1182 test output:
1183 .Sp
1184 .Vb 12
1185 \& my %callbacks = (
1186 \&     test => sub {
1187 \&         my $test = shift;
1188 \&         if ( $test\->is_ok && not $test\->directive ) {
1189 \&             # normal passing test
1190 \&             print color 'green';
1191 \&         }
1192 \&         elsif ( !$test\->is_ok ) {    # even if it's TODO
1193 \&             print color 'white on_red';
1194 \&         }
1195 \&         elsif ( $test\->has_skip ) {
1196 \&             print color 'white on_blue';
1197 .Ve
1198 .Sp
1199 .Vb 16
1200 \&         }
1201 \&         elsif ( $test\->has_todo ) {
1202 \&             print color 'white';
1203 \&         }
1204 \&     },
1205 \&     ELSE => sub {
1206 \&         # plan, comment, and so on (anything which isn't a test line)
1207 \&         print color 'black on_white';
1208 \&     },
1209 \&     ALL => sub {
1210 \&         # now print them
1211 \&         print shift\->as_string;
1212 \&         print color 'reset';
1213 \&         print "\en";
1214 \&     },
1215 \& );
1216 .Ve
1217 .ie n .IP "* ""EOF""" 4
1218 .el .IP "* \f(CWEOF\fR" 4
1219 .IX Item "EOF"
1220 Invoked when there are no more lines to be parsed. Since there is no
1221 accompanying TAP::Parser::Result object the \f(CW\*(C`TAP::Parser\*(C'\fR object is
1222 passed instead.
1223 .SH "TAP GRAMMAR"
1224 .IX Header "TAP GRAMMAR"
1225 If you're looking for an \s-1EBNF\s0 grammar, see TAP::Parser::Grammar.
1226 .SH "BACKWARDS COMPATABILITY"
1227 .IX Header "BACKWARDS COMPATABILITY"
1228 The Perl-QA list attempted to ensure backwards compatability with
1229 Test::Harness.  However, there are some minor differences.
1230 .Sh "Differences"
1231 .IX Subsection "Differences"
1232 .IP "* \s-1TODO\s0 plans" 4
1233 .IX Item "TODO plans"
1234 A little-known feature of Test::Harness is that it supported \s-1TODO\s0
1235 lists in the plan:
1236 .Sp
1237 .Vb 3
1238 \& 1..2 todo 2
1239 \& ok 1 \- We have liftoff
1240 \& not ok 2 \- Anti\-gravity device activated
1241 .Ve
1242 .Sp
1243 Under Test::Harness, test number 2 would \fIpass\fR because it was
1244 listed as a \s-1TODO\s0 test on the plan line. However, we are not aware of
1245 anyone actually using this feature and hard-coding test numbers is
1246 discouraged because it's very easy to add a test and break the test
1247 number sequence. This makes test suites very fragile. Instead, the
1248 following should be used:
1249 .Sp
1250 .Vb 3
1251 \& 1..2
1252 \& ok 1 \- We have liftoff
1253 \& not ok 2 \- Anti\-gravity device activated # TODO
1254 .Ve
1255 .IP "* 'Missing' tests" 4
1256 .IX Item "'Missing' tests"
1257 It rarely happens, but sometimes a harness might encounter
1258 \&'missing tests:
1259 .Sp
1260 .Vb 5
1261 \& ok 1
1262 \& ok 2
1263 \& ok 15
1264 \& ok 16
1265 \& ok 17
1266 .Ve
1267 .Sp
1268 Test::Harness would report tests 3\-14 as having failed. For the
1269 \&\f(CW\*(C`TAP::Parser\*(C'\fR, these tests are not considered failed because they've
1270 never run. They're reported as parse failures (tests out of sequence).
1271 .SH "SUBCLASSING"
1272 .IX Header "SUBCLASSING"
1273 If you find you need to provide custom functionality (as you would have using
1274 Test::Harness::Straps), you're in luck: \f(CW\*(C`TAP::Parser\*(C'\fR and friends are
1275 designed to be easily subclassed.
1276 .PP
1277 Before you start, it's important to know a few things:
1278 .IP "1" 2
1279 .IX Item "1"
1280 All \f(CW\*(C`TAP::*\*(C'\fR objects inherit from TAP::Object.
1281 .IP "2" 2
1282 .IX Item "2"
1283 Most \f(CW\*(C`TAP::*\*(C'\fR classes have a \fI\s-1SUBCLASSING\s0\fR section to guide you.
1284 .IP "3" 2
1285 .IX Item "3"
1286 Note that \f(CW\*(C`TAP::Parser\*(C'\fR is designed to be the central 'maker' \- ie: it is
1287 responsible for creating new objects in the \f(CW\*(C`TAP::Parser::*\*(C'\fR namespace.
1288 .Sp
1289 This makes it possible for you to have a single point of configuring what
1290 subclasses should be used, which in turn means that in many cases you'll find
1291 you only need to sub-class one of the parser's components.
1292 .IP "4" 2
1293 .IX Item "4"
1294 By subclassing, you may end up overriding undocumented methods.  That's not
1295 a bad thing per se, but be forewarned that undocumented methods may change
1296 without warning from one release to the next \- we cannot guarantee backwards
1297 compatability.  If any \fIdocumented\fR method needs changing, it will be
1298 deprecated first, and changed in a later release.
1299 .Sh "Parser Components"
1300 .IX Subsection "Parser Components"
1301 \fISources\fR
1302 .IX Subsection "Sources"
1303 .PP
1304 A \s-1TAP\s0 parser consumes input from a \fIsource\fR.  There are currently two types
1305 of sources: TAP::Parser::Source for general non-perl commands, and
1306 TAP::Parser::Source::Perl.  You can subclass both of them.  You'll need to
1307 customize your parser by setting the \f(CW\*(C`source_class\*(C'\fR & \f(CW\*(C`perl_source_class\*(C'\fR
1308 parameters.  See \*(L"new\*(R" for more details.
1309 .PP
1310 If you need to customize the objects on creation, subclass TAP::Parser and
1311 override \*(L"make_source\*(R" or \*(L"make_perl_source\*(R".
1312 .PP
1313 \fIIterators\fR
1314 .IX Subsection "Iterators"
1315 .PP
1316 A \s-1TAP\s0 parser uses \fIiterators\fR to loop through the \fIstream\fR provided by the
1317 parser's \fIsource\fR.  There are quite a few types of Iterators available.
1318 Choosing which class to use is the responsibility of the \fIiterator factory\fR.
1319 .PP
1320 To create your own iterators you'll have to subclass
1321 TAP::Parser::IteratorFactory and TAP::Parser::Iterator.  Then you'll
1322 need to customize the class used by your parser by setting the
1323 \&\f(CW\*(C`iterator_factory_class\*(C'\fR parameter.  See \*(L"new\*(R" for more details.
1324 .PP
1325 If you need to customize the objects on creation, subclass TAP::Parser and
1326 override \*(L"make_iterator\*(R".
1327 .PP
1328 \fIResults\fR
1329 .IX Subsection "Results"
1330 .PP
1331 A \s-1TAP\s0 parser creates TAP::Parser::Results as it iterates through the
1332 input \fIstream\fR.  There are quite a few result types available; choosing
1333 which class to use is the responsibility of the \fIresult factory\fR.
1334 .PP
1335 To create your own result types you have two options:
1336 .IP "option 1" 2
1337 .IX Item "option 1"
1338 Subclass TAP::Parser::Result and register your new result type/class with
1339 the default TAP::Parser::ResultFactory.
1340 .IP "option 2" 2
1341 .IX Item "option 2"
1342 Subclass TAP::Parser::ResultFactory itself and implement your own
1343 TAP::Parser::Result creation logic.  Then you'll need to customize the
1344 class used by your parser by setting the \f(CW\*(C`result_factory_class\*(C'\fR parameter.
1345 See \*(L"new\*(R" for more details.
1346 .PP
1347 If you need to customize the objects on creation, subclass TAP::Parser and
1348 override \*(L"make_result\*(R".
1349 .PP
1350 \fIGrammar\fR
1351 .IX Subsection "Grammar"
1352 .PP
1353 TAP::Parser::Grammar is the heart of the parser \- it tokenizes the \s-1TAP\s0
1354 input \fIstream\fR and produces results.  If you need to customize its behaviour
1355 you should probably familiarize yourself with the source first.  Enough
1356 lecturing.
1357 .PP
1358 Subclass TAP::Parser::Grammar and customize your parser by setting the
1359 \&\f(CW\*(C`grammar_class\*(C'\fR parameter.  See \*(L"new\*(R" for more details.
1360 .PP
1361 If you need to customize the objects on creation, subclass TAP::Parser and
1362 override \*(L"make_grammar\*(R"
1363 .SH "ACKNOWLEDGEMENTS"
1364 .IX Header "ACKNOWLEDGEMENTS"
1365 All of the following have helped. Bug reports, patches, (im)moral
1366 support, or just words of encouragement have all been forthcoming.
1367 .IP "* Michael Schwern" 4
1368 .IX Item "Michael Schwern"
1369 .PD 0
1370 .IP "* Andy Lester" 4
1371 .IX Item "Andy Lester"
1372 .IP "* chromatic" 4
1373 .IX Item "chromatic"
1374 .IP "* \s-1GEOFFR\s0" 4
1375 .IX Item "GEOFFR"
1376 .IP "* Shlomi Fish" 4
1377 .IX Item "Shlomi Fish"
1378 .IP "* Torsten Schoenfeld" 4
1379 .IX Item "Torsten Schoenfeld"
1380 .IP "* Jerry Gay" 4
1381 .IX Item "Jerry Gay"
1382 .IP "* Aristotle" 4
1383 .IX Item "Aristotle"
1384 .IP "* Adam Kennedy" 4
1385 .IX Item "Adam Kennedy"
1386 .IP "* Yves Orton" 4
1387 .IX Item "Yves Orton"
1388 .IP "* Adrian Howard" 4
1389 .IX Item "Adrian Howard"
1390 .IP "* Sean & Lil" 4
1391 .IX Item "Sean & Lil"
1392 .IP "* Andreas J. Koenig" 4
1393 .IX Item "Andreas J. Koenig"
1394 .IP "* Florian Ragwitz" 4
1395 .IX Item "Florian Ragwitz"
1396 .IP "* Corion" 4
1397 .IX Item "Corion"
1398 .IP "* Mark Stosberg" 4
1399 .IX Item "Mark Stosberg"
1400 .IP "* Matt Kraai" 4
1401 .IX Item "Matt Kraai"
1402 .IP "* David Wheeler" 4
1403 .IX Item "David Wheeler"
1404 .IP "* Alex Vandiver" 4
1405 .IX Item "Alex Vandiver"
1406 .PD
1407 .SH "AUTHORS"
1408 .IX Header "AUTHORS"
1409 Curtis \*(L"Ovid\*(R" Poe <ovid@cpan.org>
1410 .PP
1411 Andy Armstong <andy@hexten.net>
1412 .PP
1413 Eric Wilhelm @ <ewilhelm at cpan dot org>
1414 .PP
1415 Michael Peters <mpeters at plusthree dot com>
1416 .PP
1417 Leif Eriksen <leif dot eriksen at bigpond dot com>
1418 .PP
1419 Steve Purkis <spurkis@cpan.org>
1420 .PP
1421 Nicholas Clark <nick@ccl4.org>
1422 .SH "BUGS"
1423 .IX Header "BUGS"
1424 Please report any bugs or feature requests to
1425 \&\f(CW\*(C`bug\-test\-harness@rt.cpan.org\*(C'\fR, or through the web interface at
1426 <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test\-Harness>.
1427 We will be notified, and then you'll automatically be notified of
1428 progress on your bug as we make changes.
1429 .PP
1430 Obviously, bugs which include patches are best. If you prefer, you can
1431 patch against bleed by via anonymous checkout of the latest version:
1432 .PP
1433 .Vb 1
1434 \& svn checkout http://svn.hexten.net/tapx
1435 .Ve
1436 .SH "COPYRIGHT & LICENSE"
1437 .IX Header "COPYRIGHT & LICENSE"
1438 Copyright 2006\-2008 Curtis \*(L"Ovid\*(R" Poe, all rights reserved.
1439 .PP
1440 This program is free software; you can redistribute it and/or modify it
1441 under the same terms as Perl itself.