The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Test2::Harness::Parser - Default parser, parser-dispatcher, and parser base class.

DESCRIPTION

The parser is responsible for consuming lines of output from the running test, and turning the output into Test2::Event objects.

This is the default parser. This parser inspects the output stream from the unit test and looks for the correct parser to handle it. If the output contains a line like T2_FORMATTER: Foo then this will look for Test2::Harness::Parser::FOO. If the output looks like a TAP stream then Test2::Harness::Parser::TAP will be selected.

In general a test using Test2 tools will use Test2::Harness::Parser::EventStream. However any test that loads Test::Builder directly or indirectly will use Test2::Harness::Parser::TAP as a precaution.

METHODS

$proc = $p->proc()

This returns the Test2::Harness::Proc object, which is a handle for the running test. Use this to get lines of output, or to control the child process.

$j = $p->job()

This will be an integer. This is the job number assigned to the test being parsed.

$p->morph()

When the parser decides a different parser is the correct one to use, it will re-bless itself to the new parser class and call this method. This method is your chance to make any additional changes to the parser object.

@events = $p->step()

This is called regularly by the harness. This should consume any lines of output that are available and return the Test2::Event objects produced. If there was no output to consume this should return an empty list. This should never block as it is called in an event loop.

The default version of this method will read lines of STDERR/STDOUT and attempt to find the correct subclass to use. Any lines output that do not help identify the parser are turned into simple noise/diagnostics Test2::Event objects.

If the parser is identified from the output stream the parser object will re-bless itself and call morph().

SOURCE

The source code repository for Test2-Harness can be found at http://github.com/Test-More/Test2-Harness/.

MAINTAINERS

Chad Granum <exodist@cpan.org>

AUTHORS

Chad Granum <exodist@cpan.org>

COPYRIGHT

Copyright 2016 Chad Granum <exodist7@gmail.com>.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See http://dev.perl.org/licenses/