GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  TEST2::FORMATTER::TAP (3)

.ds Aq ’

NAME

Test2::Formatter::TAP - Standard TAP formatter

CONTENTS

EXPERIMENTAL RELEASE

This is an experimental release. Using this right now is not recommended.

DESCRIPTION

This is what takes events and turns them into TAP.

SYNOPSIS



    use Test2::Formatter::TAP;
    my $tap = Test2::Formatter::TAP->new();

    # Switch to utf8
    $tap->encoding(utf8);

    $tap->write($event, $number); # Output an event



METHODS

$bool = $tap->no_numbers
$tap->set_no_numbers($bool) Use to turn numbers on and off.
$arrayref = $tap->handles
$tap->set_handles(\@handles); Can be used to get/set the filehandles. Indexes are identified by the OUT_STD and OUT_ERR constants.
$encoding = $tap->encoding
$tap->encoding($encoding) Get or set the encoding. By default no encoding is set, the original settings of STDOUT and STDERR are used.

This directly modifies the stored filehandles, it does not create new ones.

$tap->write($e, $num) Write an event to the console.
Test2::Formatter::TAP->register_event($pkg, sub { ... }); In general custom events are not supported. There are however occasions where you might want to write a custom event type that results in TAP output. In order to do this you use the register_event() class method.



    package My::Event;
    use Test2::Formatter::TAP;

    use base Test2::Event;
    use Test2::Util::HashBase accessors => [qw/pass name diag note/];

    Test2::Formatter::TAP->register_event(
        __PACKAGE__,
        sub {
            my $self = shift;
            my ($e, $num) = @_;
            return (
                [Test2::Formatter::TAP::OUT_STD, "ok $num - " . $e->name . "\n"],
                [Test2::Formatter::TAP::OUT_ERR, "# " . $e->name . " " . $e->diag . "\n"],
                [Test2::Formatter::TAP::OUT_STD, "# " . $e->name . " " . $e->note . "\n"],
            );
        }
    );

    1;



    EVENT METHODS

All these methods require the event itself. Optionally they can all except a test number.

All methods return a list of array-refs. Each array-ref will have 2 items, the first is an integer identifying an output handle, the second is a string that should be written to the handle.
@out = $TAP->event_ok($e)
@out = $TAP->event_ok($e, $num) Process an Test2::Event::Ok event.
@out = $TAP->event_plan($e)
@out = $TAP->event_plan($e, $num) Process an Test2::Event::Plan event.
@out = $TAP->event_note($e)
@out = $TAP->event_note($e, $num) Process an Test2::Event::Note event.
@out = $TAP->event_diag($e)
@out = $TAP->event_diag($e, $num) Process an Test2::Event::Diag event.
@out = $TAP->event_bail($e)
@out = $TAP->event_bail($e, $num) Process an Test2::Event::Bail event.
@out = $TAP->event_exception($e)
@out = $TAP->event_exception($e, $num) Process an Test2::Event::Exception event.
@out = $TAP->event_skip($e)
@out = $TAP->event_skip($e, $num) Process an Test2::Event::Skip event.
@out = $TAP->event_subtest($e)
@out = $TAP->event_subtest($e, $num) Process an Test2::Event::Subtest event.

SOURCE

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

MAINTAINERS

Chad Granum <exodist@cpan.org>

AUTHORS

Chad Granum <exodist@cpan.org>
Kent Fredric <kentnl@cpan.org>

COPYRIGHT

Copyright 2015 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/

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 TEST2::FORMATTER::TAP (3) 2016-04-01

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.