You are viewing the version of this documentation from Perl 5.20.3. View the latest version

CONTENTS

NAME

TAP::Parser - Parse TAP output

VERSION

Version 3.30

SYNOPSIS

use TAP::Parser;

my $parser = TAP::Parser->new( { source => $source } );

while ( my $result = $parser->next ) {
    print $result->as_string;
}

DESCRIPTION

TAP::Parser is designed to produce a proper parse of TAP output. For an example of how to run tests through this module, see the simple harnesses examples/.

There's a wiki dedicated to the Test Anything Protocol:

http://testanything.org

It includes the TAP::Parser Cookbook:

http://testanything.org/wiki/index.php/TAP::Parser_Cookbook

METHODS

Class Methods

new

my $parser = TAP::Parser->new(\%args);

Returns a new TAP::Parser object.

The arguments should be a hashref with one of the following keys:

The following keys are optional.

Instance Methods

next

my $parser = TAP::Parser->new( { source => $file } );
while ( my $result = $parser->next ) {
    print $result->as_string, "\n";
}

This method returns the results of the parsing, one result at a time. Note that it is destructive. You can't rewind and examine previous results.

If callbacks are used, they will be issued before this call returns.

Each result returned is a subclass of TAP::Parser::Result. See that module and related classes for more information on how to use them.

run

$parser->run;

This method merely runs the parser and parses all of the TAP.

make_grammar

Make a new TAP::Parser::Grammar object and return it. Passes through any arguments given.

The grammar_class can be customized, as described in "new".

make_result

Make a new TAP::Parser::Result object using the parser's TAP::Parser::ResultFactory, and return it. Passes through any arguments given.

The result_factory_class can be customized, as described in "new".

make_iterator_factory

NEW to 3.18.

Make a new TAP::Parser::IteratorFactory object and return it. Passes through any arguments given.

iterator_factory_class can be customized, as described in "new".

INDIVIDUAL RESULTS

If you've read this far in the docs, you've seen this:

while ( my $result = $parser->next ) {
    print $result->as_string;
}

Each result returned is a TAP::Parser::Result subclass, referred to as result types.

Result types

Basically, you fetch individual results from the TAP. The six types, with examples of each, are as follows:

Each result fetched is a result object of a different type. There are common methods to each result object and different types may have methods unique to their type. Sometimes a type method may be overridden in a subclass, but its use is guaranteed to be identical.

Common type methods

type

Returns the type of result, such as comment or test.