NAME

Test::ParallelSubtest::Capture - capture Test::Builder output

SYNOPSIS

my $capture = Test::ParallelSubtest::Capture->new;

$capture->install(Test::Builder->new);

ok 1, 'blah';
# ...

$capture->replay_writes(\*STDOUT, \*STDERR, \*STDOUT);

DESCRIPTION

A helper class for Test::ParallelSubtest, allowing all Test::Builder output generated in the child process to be buffered and passed to the parent process for printing.

For now this class is private to Test::ParallelSubtest, and it may change or vanish without notice. If anyone wants to use this outside of Test::ParallelSubtest, please drop me a line and I'll make it into a separate package under a new name.

METHODS

new ( [BUFREF] )

Creates a new output capture object. If BUFREF is supplied then it must be a reference to a scalar holding the buffer contents returned by the as_string_ref() method of a Test::ParallelSubtest::Capture object.

install ( BUILDER )

BUILDER must be a Test::Builder object.

Installs the capture object as BUILDER's destination for all test output. Test output will now accumulate in the capture object until BUILDER's outputs are redirected elsewhere.

as_string_ref ()

Returns a reference to a string that encodes the sequence of writes so far. The string is suitable for passing to new() to build a new capture object holding the same the sequence of writes.

replay_writes ( OUT_DEST, FAIL_DEST, TODO_DEST )

Replays the captured sequence of writes. The parameters must be file handles, and each will receive writes of a particular type. See "output" in Test::Builder.

Returns true on success, false if the internal buffer cannot be decoded because a malformed buffer was passed to new().

AUTHOR

Nick Cleaton, <nick@cleaton.net>

COPYRIGHT AND LICENSE

Copyright (C) 2010 by Nick Cleaton

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.