1TAP::Parser(3pm) Perl Programmers Reference Guide TAP::Parser(3pm)
2
3
4
6 TAP::Parser - Parse TAP output
7
9 Version 3.17
10
12 use TAP::Parser;
13
14 my $parser = TAP::Parser->new( { source => $source } );
15
16 while ( my $result = $parser->next ) {
17 print $result->as_string;
18 }
19
21 "TAP::Parser" is designed to produce a proper parse of TAP output. For
22 an example of how to run tests through this module, see the simple
23 harnesses "examples/".
24
25 There's a wiki dedicated to the Test Anything Protocol:
26
27 <http://testanything.org>
28
29 It includes the TAP::Parser Cookbook:
30
31 <http://testanything.org/wiki/index.php/TAP::Parser_Cookbook>
32
34 Class Methods
35 "new"
36
37 my $parser = TAP::Parser->new(\%args);
38
39 Returns a new "TAP::Parser" object.
40
41 The arguments should be a hashref with one of the following keys:
42
43 · "source"
44
45 This is the preferred method of passing arguments to the
46 constructor. To determine how to handle the source, the following
47 steps are taken.
48
49 If the source contains a newline, it's assumed to be a string of
50 raw TAP output.
51
52 If the source is a reference, it's assumed to be something to pass
53 to the TAP::Parser::Iterator::Stream constructor. This is used
54 internally and you should not use it.
55
56 Otherwise, the parser does a "-e" check to see if the source
57 exists. If so, it attempts to execute the source and read the
58 output as a stream. This is by far the preferred method of using
59 the parser.
60
61 foreach my $file ( @test_files ) {
62 my $parser = TAP::Parser->new( { source => $file } );
63 # do stuff with the parser
64 }
65
66 · "tap"
67
68 The value should be the complete TAP output.
69
70 · "exec"
71
72 If passed an array reference, will attempt to create the iterator
73 by passing a TAP::Parser::Source object to
74 TAP::Parser::Iterator::Source, using the array reference strings as
75 the command arguments to IPC::Open3::open3:
76
77 exec => [ '/usr/bin/ruby', 't/my_test.rb' ]
78
79 Note that "source" and "exec" are mutually exclusive.
80
81 The following keys are optional.
82
83 · "callback"
84
85 If present, each callback corresponding to a given result type will
86 be called with the result as the argument if the "run" method is
87 used:
88
89 my %callbacks = (
90 test => \&test_callback,
91 plan => \&plan_callback,
92 comment => \&comment_callback,
93 bailout => \&bailout_callback,
94 unknown => \&unknown_callback,
95 );
96
97 my $aggregator = TAP::Parser::Aggregator->new;
98 foreach my $file ( @test_files ) {
99 my $parser = TAP::Parser->new(
100 {
101 source => $file,
102 callbacks => \%callbacks,
103 }
104 );
105 $parser->run;
106 $aggregator->add( $file, $parser );
107 }
108
109 · "switches"
110
111 If using a Perl file as a source, optional switches may be passed
112 which will be used when invoking the perl executable.
113
114 my $parser = TAP::Parser->new( {
115 source => $test_file,
116 switches => '-Ilib',
117 } );
118
119 · "test_args"
120
121 Used in conjunction with the "source" option to supply a reference
122 to an @ARGV style array of arguments to pass to the test program.
123
124 · "spool"
125
126 If passed a filehandle will write a copy of all parsed TAP to that
127 handle.
128
129 · "merge"
130
131 If false, STDERR is not captured (though it is 'relayed' to keep it
132 somewhat synchronized with STDOUT.)
133
134 If true, STDERR and STDOUT are the same filehandle. This may cause
135 breakage if STDERR contains anything resembling TAP format, but
136 does allow exact synchronization.
137
138 Subtleties of this behavior may be platform-dependent and may
139 change in the future.
140
141 · "source_class"
142
143 This option was introduced to let you easily customize which source
144 class the parser should use. It defaults to TAP::Parser::Source.
145
146 See also "make_source".
147
148 · "perl_source_class"
149
150 This option was introduced to let you easily customize which perl
151 source class the parser should use. It defaults to
152 TAP::Parser::Source::Perl.
153
154 See also "make_perl_source".
155
156 · "grammar_class"
157
158 This option was introduced to let you easily customize which
159 grammar class the parser should use. It defaults to
160 TAP::Parser::Grammar.
161
162 See also "make_grammar".
163
164 · "iterator_factory_class"
165
166 This option was introduced to let you easily customize which
167 iterator factory class the parser should use. It defaults to
168 TAP::Parser::IteratorFactory.
169
170 See also "make_iterator".
171
172 · "result_factory_class"
173
174 This option was introduced to let you easily customize which result
175 factory class the parser should use. It defaults to
176 TAP::Parser::ResultFactory.
177
178 See also "make_result".
179
180 Instance Methods
181 "next"
182
183 my $parser = TAP::Parser->new( { source => $file } );
184 while ( my $result = $parser->next ) {
185 print $result->as_string, "\n";
186 }
187
188 This method returns the results of the parsing, one result at a time.
189 Note that it is destructive. You can't rewind and examine previous
190 results.
191
192 If callbacks are used, they will be issued before this call returns.
193
194 Each result returned is a subclass of TAP::Parser::Result. See that
195 module and related classes for more information on how to use them.
196
197 "run"
198
199 $parser->run;
200
201 This method merely runs the parser and parses all of the TAP.
202
203 "make_source"
204
205 Make a new TAP::Parser::Source object and return it. Passes through
206 any arguments given.
207
208 The "source_class" can be customized, as described in "new".
209
210 "make_perl_source"
211
212 Make a new TAP::Parser::Source::Perl object and return it. Passes
213 through any arguments given.
214
215 The "perl_source_class" can be customized, as described in "new".
216
217 "make_grammar"
218
219 Make a new TAP::Parser::Grammar object and return it. Passes through
220 any arguments given.
221
222 The "grammar_class" can be customized, as described in "new".
223
224 "make_iterator"
225
226 Make a new TAP::Parser::Iterator object using the parser's
227 TAP::Parser::IteratorFactory, and return it. Passes through any
228 arguments given.
229
230 The "iterator_factory_class" can be customized, as described in "new".
231
232 "make_result"
233
234 Make a new TAP::Parser::Result object using the parser's
235 TAP::Parser::ResultFactory, and return it. Passes through any
236 arguments given.
237
238 The "result_factory_class" can be customized, as described in "new".
239
241 If you've read this far in the docs, you've seen this:
242
243 while ( my $result = $parser->next ) {
244 print $result->as_string;
245 }
246
247 Each result returned is a TAP::Parser::Result subclass, referred to as
248 result types.
249
250 Result types
251 Basically, you fetch individual results from the TAP. The six types,
252 with examples of each, are as follows:
253
254 · Version
255
256 TAP version 12
257
258 · Plan
259
260 1..42
261
262 · Pragma
263
264 pragma +strict
265
266 · Test
267
268 ok 3 - We should start with some foobar!
269
270 · Comment
271
272 # Hope we don't use up the foobar.
273
274 · Bailout
275
276 Bail out! We ran out of foobar!
277
278 · Unknown
279
280 ... yo, this ain't TAP! ...
281
282 Each result fetched is a result object of a different type. There are
283 common methods to each result object and different types may have
284 methods unique to their type. Sometimes a type method may be
285 overridden in a subclass, but its use is guaranteed to be identical.
286
287 Common type methods
288 "type"
289
290 Returns the type of result, such as "comment" or "test".
291
292 "as_string"
293
294 Prints a string representation of the token. This might not be the
295 exact output, however. Tests will have test numbers added if not
296 present, TODO and SKIP directives will be capitalized and, in general,
297 things will be cleaned up. If you need the original text for the
298 token, see the "raw" method.
299
300 "raw"
301
302 Returns the original line of text which was parsed.
303
304 "is_plan"
305
306 Indicates whether or not this is the test plan line.
307
308 "is_test"
309
310 Indicates whether or not this is a test line.
311
312 "is_comment"
313
314 Indicates whether or not this is a comment. Comments will generally
315 only appear in the TAP stream if STDERR is merged to STDOUT. See the
316 "merge" option.
317
318 "is_bailout"
319
320 Indicates whether or not this is bailout line.
321
322 "is_yaml"
323
324 Indicates whether or not the current item is a YAML block.
325
326 "is_unknown"
327
328 Indicates whether or not the current line could be parsed.
329
330 "is_ok"
331
332 if ( $result->is_ok ) { ... }
333
334 Reports whether or not a given result has passed. Anything which is
335 not a test result returns true. This is merely provided as a
336 convenient shortcut which allows you to do this:
337
338 my $parser = TAP::Parser->new( { source => $source } );
339 while ( my $result = $parser->next ) {
340 # only print failing results
341 print $result->as_string unless $result->is_ok;
342 }
343
344 "plan" methods
345 if ( $result->is_plan ) { ... }
346
347 If the above evaluates as true, the following methods will be available
348 on the $result object.
349
350 "plan"
351
352 if ( $result->is_plan ) {
353 print $result->plan;
354 }
355
356 This is merely a synonym for "as_string".
357
358 "directive"
359
360 my $directive = $result->directive;
361
362 If a SKIP directive is included with the plan, this method will return
363 it.
364
365 1..0 # SKIP: why bother?
366
367 "explanation"
368
369 my $explanation = $result->explanation;
370
371 If a SKIP directive was included with the plan, this method will return
372 the explanation, if any.
373
374 "pragma" methods
375 if ( $result->is_pragma ) { ... }
376
377 If the above evaluates as true, the following methods will be available
378 on the $result object.
379
380 "pragmas"
381
382 Returns a list of pragmas each of which is a + or - followed by the
383 pragma name.
384
385 "commment" methods
386 if ( $result->is_comment ) { ... }
387
388 If the above evaluates as true, the following methods will be available
389 on the $result object.
390
391 "comment"
392
393 if ( $result->is_comment ) {
394 my $comment = $result->comment;
395 print "I have something to say: $comment";
396 }
397
398 "bailout" methods
399 if ( $result->is_bailout ) { ... }
400
401 If the above evaluates as true, the following methods will be available
402 on the $result object.
403
404 "explanation"
405
406 if ( $result->is_bailout ) {
407 my $explanation = $result->explanation;
408 print "We bailed out because ($explanation)";
409 }
410
411 If, and only if, a token is a bailout token, you can get an
412 "explanation" via this method. The explanation is the text after the
413 mystical "Bail out!" words which appear in the tap output.
414
415 "unknown" methods
416 if ( $result->is_unknown ) { ... }
417
418 There are no unique methods for unknown results.
419
420 "test" methods
421 if ( $result->is_test ) { ... }
422
423 If the above evaluates as true, the following methods will be available
424 on the $result object.
425
426 "ok"
427
428 my $ok = $result->ok;
429
430 Returns the literal text of the "ok" or "not ok" status.
431
432 "number"
433
434 my $test_number = $result->number;
435
436 Returns the number of the test, even if the original TAP output did not
437 supply that number.
438
439 "description"
440
441 my $description = $result->description;
442
443 Returns the description of the test, if any. This is the portion after
444 the test number but before the directive.
445
446 "directive"
447
448 my $directive = $result->directive;
449
450 Returns either "TODO" or "SKIP" if either directive was present for a
451 test line.
452
453 "explanation"
454
455 my $explanation = $result->explanation;
456
457 If a test had either a "TODO" or "SKIP" directive, this method will
458 return the accompanying explantion, if present.
459
460 not ok 17 - 'Pigs can fly' # TODO not enough acid
461
462 For the above line, the explanation is not enough acid.
463
464 "is_ok"
465
466 if ( $result->is_ok ) { ... }
467
468 Returns a boolean value indicating whether or not the test passed.
469 Remember that for TODO tests, the test always passes.
470
471 Note: this was formerly "passed". The latter method is deprecated and
472 will issue a warning.
473
474 "is_actual_ok"
475
476 if ( $result->is_actual_ok ) { ... }
477
478 Returns a boolean value indicating whether or not the test passed,
479 regardless of its TODO status.
480
481 Note: this was formerly "actual_passed". The latter method is
482 deprecated and will issue a warning.
483
484 "is_unplanned"
485
486 if ( $test->is_unplanned ) { ... }
487
488 If a test number is greater than the number of planned tests, this
489 method will return true. Unplanned tests will always return false for
490 "is_ok", regardless of whether or not the test "has_todo" (see
491 TAP::Parser::Result::Test for more information about this).
492
493 "has_skip"
494
495 if ( $result->has_skip ) { ... }
496
497 Returns a boolean value indicating whether or not this test had a SKIP
498 directive.
499
500 "has_todo"
501
502 if ( $result->has_todo ) { ... }
503
504 Returns a boolean value indicating whether or not this test had a TODO
505 directive.
506
507 Note that TODO tests always pass. If you need to know whether or not
508 they really passed, check the "is_actual_ok" method.
509
510 "in_todo"
511
512 if ( $parser->in_todo ) { ... }
513
514 True while the most recent result was a TODO. Becomes true before the
515 TODO result is returned and stays true until just before the next non-
516 TODO test is returned.
517
519 After parsing the TAP, there are many methods available to let you dig
520 through the results and determine what is meaningful to you.
521
522 Individual Results
523 These results refer to individual tests which are run.
524
525 "passed"
526
527 my @passed = $parser->passed; # the test numbers which passed
528 my $passed = $parser->passed; # the number of tests which passed
529
530 This method lets you know which (or how many) tests passed. If a test
531 failed but had a TODO directive, it will be counted as a passed test.
532
533 "failed"
534
535 my @failed = $parser->failed; # the test numbers which failed
536 my $failed = $parser->failed; # the number of tests which failed
537
538 This method lets you know which (or how many) tests failed. If a test
539 passed but had a TODO directive, it will NOT be counted as a failed
540 test.
541
542 "actual_passed"
543
544 # the test numbers which actually passed
545 my @actual_passed = $parser->actual_passed;
546
547 # the number of tests which actually passed
548 my $actual_passed = $parser->actual_passed;
549
550 This method lets you know which (or how many) tests actually passed,
551 regardless of whether or not a TODO directive was found.
552
553 "actual_ok"
554
555 This method is a synonym for "actual_passed".
556
557 "actual_failed"
558
559 # the test numbers which actually failed
560 my @actual_failed = $parser->actual_failed;
561
562 # the number of tests which actually failed
563 my $actual_failed = $parser->actual_failed;
564
565 This method lets you know which (or how many) tests actually failed,
566 regardless of whether or not a TODO directive was found.
567
568 "todo"
569
570 my @todo = $parser->todo; # the test numbers with todo directives
571 my $todo = $parser->todo; # the number of tests with todo directives
572
573 This method lets you know which (or how many) tests had TODO
574 directives.
575
576 "todo_passed"
577
578 # the test numbers which unexpectedly succeeded
579 my @todo_passed = $parser->todo_passed;
580
581 # the number of tests which unexpectedly succeeded
582 my $todo_passed = $parser->todo_passed;
583
584 This method lets you know which (or how many) tests actually passed but
585 were declared as "TODO" tests.
586
587 "todo_failed"
588
589 # deprecated in favor of 'todo_passed'. This method was horribly misnamed.
590
591 This was a badly misnamed method. It indicates which TODO tests
592 unexpectedly succeeded. Will now issue a warning and call
593 "todo_passed".
594
595 "skipped"
596
597 my @skipped = $parser->skipped; # the test numbers with SKIP directives
598 my $skipped = $parser->skipped; # the number of tests with SKIP directives
599
600 This method lets you know which (or how many) tests had SKIP
601 directives.
602
603 Pragmas
604 "pragma"
605
606 Get or set a pragma. To get the state of a pragma:
607
608 if ( $p->pragma('strict') ) {
609 # be strict
610 }
611
612 To set the state of a pragma:
613
614 $p->pragma('strict', 1); # enable strict mode
615
616 "pragmas"
617
618 Get a list of all the currently enabled pragmas:
619
620 my @pragmas_enabled = $p->pragmas;
621
622 Summary Results
623 These results are "meta" information about the total results of an
624 individual test program.
625
626 "plan"
627
628 my $plan = $parser->plan;
629
630 Returns the test plan, if found.
631
632 "good_plan"
633
634 Deprecated. Use "is_good_plan" instead.
635
636 "is_good_plan"
637
638 if ( $parser->is_good_plan ) { ... }
639
640 Returns a boolean value indicating whether or not the number of tests
641 planned matches the number of tests run.
642
643 Note: this was formerly "good_plan". The latter method is deprecated
644 and will issue a warning.
645
646 And since we're on that subject ...
647
648 "tests_planned"
649
650 print $parser->tests_planned;
651
652 Returns the number of tests planned, according to the plan. For
653 example, a plan of '1..17' will mean that 17 tests were planned.
654
655 "tests_run"
656
657 print $parser->tests_run;
658
659 Returns the number of tests which actually were run. Hopefully this
660 will match the number of "$parser->tests_planned".
661
662 "skip_all"
663
664 Returns a true value (actually the reason for skipping) if all tests
665 were skipped.
666
667 "start_time"
668
669 Returns the time when the Parser was created.
670
671 "end_time"
672
673 Returns the time when the end of TAP input was seen.
674
675 "has_problems"
676
677 if ( $parser->has_problems ) {
678 ...
679 }
680
681 This is a 'catch-all' method which returns true if any tests have
682 currently failed, any TODO tests unexpectedly succeeded, or any parse
683 errors occurred.
684
685 "version"
686
687 $parser->version;
688
689 Once the parser is done, this will return the version number for the
690 parsed TAP. Version numbers were introduced with TAP version 13 so if
691 no version number is found version 12 is assumed.
692
693 "exit"
694
695 $parser->exit;
696
697 Once the parser is done, this will return the exit status. If the
698 parser ran an executable, it returns the exit status of the executable.
699
700 "wait"
701
702 $parser->wait;
703
704 Once the parser is done, this will return the wait status. If the
705 parser ran an executable, it returns the wait status of the executable.
706 Otherwise, this mererely returns the "exit" status.
707
708 "ignore_exit"
709 $parser->ignore_exit(1);
710
711 Tell the parser to ignore the exit status from the test when
712 determining whether the test passed. Normally tests with non-zero exit
713 status are considered to have failed even if all individual tests
714 passed. In cases where it is not possible to control the exit value of
715 the test script use this option to ignore it.
716
717 "parse_errors"
718
719 my @errors = $parser->parse_errors; # the parser errors
720 my $errors = $parser->parse_errors; # the number of parser_errors
721
722 Fortunately, all TAP output is perfect. In the event that it is not,
723 this method will return parser errors. Note that a junk line which the
724 parser does not recognize is "not" an error. This allows this parser
725 to handle future versions of TAP. The following are all TAP errors
726 reported by the parser:
727
728 · Misplaced plan
729
730 The plan (for example, '1..5'), must only come at the beginning or
731 end of the TAP output.
732
733 · No plan
734
735 Gotta have a plan!
736
737 · More than one plan
738
739 1..3
740 ok 1 - input file opened
741 not ok 2 - first line of the input valid # todo some data
742 ok 3 read the rest of the file
743 1..3
744
745 Right. Very funny. Don't do that.
746
747 · Test numbers out of sequence
748
749 1..3
750 ok 1 - input file opened
751 not ok 2 - first line of the input valid # todo some data
752 ok 2 read the rest of the file
753
754 That last test line above should have the number '3' instead of
755 '2'.
756
757 Note that it's perfectly acceptable for some lines to have test
758 numbers and others to not have them. However, when a test number
759 is found, it must be in sequence. The following is also an error:
760
761 1..3
762 ok 1 - input file opened
763 not ok - first line of the input valid # todo some data
764 ok 2 read the rest of the file
765
766 But this is not:
767
768 1..3
769 ok - input file opened
770 not ok - first line of the input valid # todo some data
771 ok 3 read the rest of the file
772
773 "get_select_handles"
774
775 Get an a list of file handles which can be passed to "select" to
776 determine the readiness of this parser.
777
778 "delete_spool"
779
780 Delete and return the spool.
781
782 my $fh = $parser->delete_spool;
783
785 As mentioned earlier, a "callback" key may be added to the
786 "TAP::Parser" constructor. If present, each callback corresponding to a
787 given result type will be called with the result as the argument if the
788 "run" method is used. The callback is expected to be a subroutine
789 reference (or anonymous subroutine) which is invoked with the parser
790 result as its argument.
791
792 my %callbacks = (
793 test => \&test_callback,
794 plan => \&plan_callback,
795 comment => \&comment_callback,
796 bailout => \&bailout_callback,
797 unknown => \&unknown_callback,
798 );
799
800 my $aggregator = TAP::Parser::Aggregator->new;
801 foreach my $file ( @test_files ) {
802 my $parser = TAP::Parser->new(
803 {
804 source => $file,
805 callbacks => \%callbacks,
806 }
807 );
808 $parser->run;
809 $aggregator->add( $file, $parser );
810 }
811
812 Callbacks may also be added like this:
813
814 $parser->callback( test => \&test_callback );
815 $parser->callback( plan => \&plan_callback );
816
817 The following keys allowed for callbacks. These keys are case-
818 sensitive.
819
820 · "test"
821
822 Invoked if "$result->is_test" returns true.
823
824 · "version"
825
826 Invoked if "$result->is_version" returns true.
827
828 · "plan"
829
830 Invoked if "$result->is_plan" returns true.
831
832 · "comment"
833
834 Invoked if "$result->is_comment" returns true.
835
836 · "bailout"
837
838 Invoked if "$result->is_unknown" returns true.
839
840 · "yaml"
841
842 Invoked if "$result->is_yaml" returns true.
843
844 · "unknown"
845
846 Invoked if "$result->is_unknown" returns true.
847
848 · "ELSE"
849
850 If a result does not have a callback defined for it, this callback
851 will be invoked. Thus, if all of the previous result types are
852 specified as callbacks, this callback will never be invoked.
853
854 · "ALL"
855
856 This callback will always be invoked and this will happen for each
857 result after one of the above callbacks is invoked. For example,
858 if Term::ANSIColor is loaded, you could use the following to color
859 your test output:
860
861 my %callbacks = (
862 test => sub {
863 my $test = shift;
864 if ( $test->is_ok && not $test->directive ) {
865 # normal passing test
866 print color 'green';
867 }
868 elsif ( !$test->is_ok ) { # even if it's TODO
869 print color 'white on_red';
870 }
871 elsif ( $test->has_skip ) {
872 print color 'white on_blue';
873
874 }
875 elsif ( $test->has_todo ) {
876 print color 'white';
877 }
878 },
879 ELSE => sub {
880 # plan, comment, and so on (anything which isn't a test line)
881 print color 'black on_white';
882 },
883 ALL => sub {
884 # now print them
885 print shift->as_string;
886 print color 'reset';
887 print "\n";
888 },
889 );
890
891 · "EOF"
892
893 Invoked when there are no more lines to be parsed. Since there is
894 no accompanying TAP::Parser::Result object the "TAP::Parser" object
895 is passed instead.
896
898 If you're looking for an EBNF grammar, see TAP::Parser::Grammar.
899
901 The Perl-QA list attempted to ensure backwards compatability with
902 Test::Harness. However, there are some minor differences.
903
904 Differences
905 · TODO plans
906
907 A little-known feature of Test::Harness is that it supported TODO
908 lists in the plan:
909
910 1..2 todo 2
911 ok 1 - We have liftoff
912 not ok 2 - Anti-gravity device activated
913
914 Under Test::Harness, test number 2 would pass because it was listed
915 as a TODO test on the plan line. However, we are not aware of
916 anyone actually using this feature and hard-coding test numbers is
917 discouraged because it's very easy to add a test and break the test
918 number sequence. This makes test suites very fragile. Instead, the
919 following should be used:
920
921 1..2
922 ok 1 - We have liftoff
923 not ok 2 - Anti-gravity device activated # TODO
924
925 · 'Missing' tests
926
927 It rarely happens, but sometimes a harness might encounter 'missing
928 tests:
929
930 ok 1
931 ok 2
932 ok 15
933 ok 16
934 ok 17
935
936 Test::Harness would report tests 3-14 as having failed. For the
937 "TAP::Parser", these tests are not considered failed because
938 they've never run. They're reported as parse failures (tests out of
939 sequence).
940
942 If you find you need to provide custom functionality (as you would have
943 using Test::Harness::Straps), you're in luck: "TAP::Parser" and friends
944 are designed to be easily subclassed.
945
946 Before you start, it's important to know a few things:
947
948 1.
949 All "TAP::*" objects inherit from TAP::Object.
950
951 2.
952 Most "TAP::*" classes have a SUBCLASSING section to guide you.
953
954 3.
955 Note that "TAP::Parser" is designed to be the central 'maker' - ie:
956 it is responsible for creating new objects in the "TAP::Parser::*"
957 namespace.
958
959 This makes it possible for you to have a single point of configuring
960 what subclasses should be used, which in turn means that in many
961 cases you'll find you only need to sub-class one of the parser's
962 components.
963
964 4.
965 By subclassing, you may end up overriding undocumented methods.
966 That's not a bad thing per se, but be forewarned that undocumented
967 methods may change without warning from one release to the next - we
968 cannot guarantee backwards compatability. If any documented method
969 needs changing, it will be deprecated first, and changed in a later
970 release.
971
972 Parser Components
973 Sources
974
975 A TAP parser consumes input from a source. There are currently two
976 types of sources: TAP::Parser::Source for general non-perl commands,
977 and TAP::Parser::Source::Perl. You can subclass both of them. You'll
978 need to customize your parser by setting the "source_class" &
979 "perl_source_class" parameters. See "new" for more details.
980
981 If you need to customize the objects on creation, subclass TAP::Parser
982 and override "make_source" or "make_perl_source".
983
984 Iterators
985
986 A TAP parser uses iterators to loop through the stream provided by the
987 parser's source. There are quite a few types of Iterators available.
988 Choosing which class to use is the responsibility of the iterator
989 factory.
990
991 To create your own iterators you'll have to subclass
992 TAP::Parser::IteratorFactory and TAP::Parser::Iterator. Then you'll
993 need to customize the class used by your parser by setting the
994 "iterator_factory_class" parameter. See "new" for more details.
995
996 If you need to customize the objects on creation, subclass TAP::Parser
997 and override "make_iterator".
998
999 Results
1000
1001 A TAP parser creates TAP::Parser::Results as it iterates through the
1002 input stream. There are quite a few result types available; choosing
1003 which class to use is the responsibility of the result factory.
1004
1005 To create your own result types you have two options:
1006
1007 option 1
1008 Subclass TAP::Parser::Result and register your new result type/class
1009 with the default TAP::Parser::ResultFactory.
1010
1011 option 2
1012 Subclass TAP::Parser::ResultFactory itself and implement your own
1013 TAP::Parser::Result creation logic. Then you'll need to customize
1014 the class used by your parser by setting the "result_factory_class"
1015 parameter. See "new" for more details.
1016
1017 If you need to customize the objects on creation, subclass TAP::Parser
1018 and override "make_result".
1019
1020 Grammar
1021
1022 TAP::Parser::Grammar is the heart of the parser - it tokenizes the TAP
1023 input stream and produces results. If you need to customize its
1024 behaviour you should probably familiarize yourself with the source
1025 first. Enough lecturing.
1026
1027 Subclass TAP::Parser::Grammar and customize your parser by setting the
1028 "grammar_class" parameter. See "new" for more details.
1029
1030 If you need to customize the objects on creation, subclass TAP::Parser
1031 and override "make_grammar"
1032
1034 All of the following have helped. Bug reports, patches, (im)moral
1035 support, or just words of encouragement have all been forthcoming.
1036
1037 · Michael Schwern
1038
1039 · Andy Lester
1040
1041 · chromatic
1042
1043 · GEOFFR
1044
1045 · Shlomi Fish
1046
1047 · Torsten Schoenfeld
1048
1049 · Jerry Gay
1050
1051 · Aristotle
1052
1053 · Adam Kennedy
1054
1055 · Yves Orton
1056
1057 · Adrian Howard
1058
1059 · Sean & Lil
1060
1061 · Andreas J. Koenig
1062
1063 · Florian Ragwitz
1064
1065 · Corion
1066
1067 · Mark Stosberg
1068
1069 · Matt Kraai
1070
1071 · David Wheeler
1072
1073 · Alex Vandiver
1074
1076 Curtis "Ovid" Poe <ovid@cpan.org>
1077
1078 Andy Armstong <andy@hexten.net>
1079
1080 Eric Wilhelm @ <ewilhelm at cpan dot org>
1081
1082 Michael Peters <mpeters at plusthree dot com>
1083
1084 Leif Eriksen <leif dot eriksen at bigpond dot com>
1085
1086 Steve Purkis <spurkis@cpan.org>
1087
1088 Nicholas Clark <nick@ccl4.org>
1089
1091 Please report any bugs or feature requests to
1092 "bug-test-harness@rt.cpan.org", or through the web interface at
1093 http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Harness
1094 <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Harness>. We will
1095 be notified, and then you'll automatically be notified of progress on
1096 your bug as we make changes.
1097
1098 Obviously, bugs which include patches are best. If you prefer, you can
1099 patch against bleed by via anonymous checkout of the latest version:
1100
1101 svn checkout http://svn.hexten.net/tapx
1102
1104 Copyright 2006-2008 Curtis "Ovid" Poe, all rights reserved.
1105
1106 This program is free software; you can redistribute it and/or modify it
1107 under the same terms as Perl itself.
1108
1109
1110
1111perl v5.12.4 2011-06-07 TAP::Parser(3pm)