Test::Stream::Sync(3)

NAME
Test::Stream::Sync - Primary Synchronization point, this is where global stuff lives.

DEPRECATED
This distribution is deprecated in favor of Test2, Test2::Suite, and Test2::Workflow.

See Test::Stream::Manual::ToTest2 for a conversion guide.

***INTERNALS NOTE***
The internals of this package are subject to change at any time! The public methods provided will not change in backwords incompatible ways, but the underlying implementation details might. Do not break encapsulation here!

DESCRIPTION
There is a need to synchronize some details for all tests that run. This package stores these global objects. As little as possible is kept here, when possible things should not be global.

SYNOPSIS
    use Test::Stream::Sync; # No Exports

    my $init  = Test::Stream::Sync->init_done;
    my $stack = Test::Stream::Sync->stack;
    my $ipc   = Test::Stream::Sync->ipc;

    Test::Stream::Sync->set_formatter($FORMATTER)
    my $formatter = Test::Stream::Sync->formatter;

CLASS METHODS
This class stores global instances of things. This package is NOT an object, everything that uses it will get the same stuff.

$bool = Test::Stream::Sync->init_done
    This will return true if the stack and ipc instances have already been initialized. It will return false if they have not.

$stack = Test::Stream::Sync->stack
    This will return the global Test::Stream::Stack instance. If this has not yet been initialized it will be initialized now.

$ipc = Test::Stream::Sync->ipc
    This will return the global Test::Stream::IPC instance. If this has not yet been initialized it will be initialized now.

$formatter = Test::Stream::Sync->formatter
    This will return the global formatter class. This is not an instance. By default the formatter is set to Test::Stream::Formatter::TAP.

    You can override this default using the "TS_FORMATTER" environment variable.

    Normally 'Test::Stream::Formatter::' is prefixed to the value in the environment variable:

        $ TS_FORMATTER='TAP' perl test.t     # Use the Test::Stream::Formatter::TAP formatter
        $ TS_FORMATTER='Foo' perl test.t     # Use the Test::Stream::Formatter::Foo formatter

    If you want to specify a full module name you use the '+' prefix:

        $ TS_FORMATTER='+Foo::Bar' perl test.t     # Use the Foo::Bar formatter

Test::Stream::Sync->set_formatter($class)
    Set the global formatter class. This can only be set once. Note: This will override anything specified in the 'TS_FORMATTER' environment variable.

$bool = Test::Stream::Sync->no_wait
Test::Stream::Sync->no_wait($bool)
    This can be used to get/set the no_wait status. Waiting is turned on by default. Waiting will cause the parent process/thread to wait until all child processes and threads are finished before exiting. You will almost never want to turn this off.

Test::Stream::Sync->add_hook(sub { ... })
    This can be used to add a hook that is called after all testing is done. This is too late to add additional results, the main use of this hook is to set the exit code.

        Test::Stream::Sync->add_hook(
            sub {
                my ($context, $exit, \$new_exit) = @_;
                ...
            }
        );

    The $context passed in will be an instance of Test::Stream::Context. The $exit argument will be the original exit code before anything modified it. $$new_exit is a reference to the new exit code. You may modify this to change the exit code. Please note that $$new_exit may already be different from $exit

Test::Stream::Sync->post_load(sub { ... })
    Add a callback that will be called when Test::Stream is finished loading. This means the callback will be run when Test::Stream is done loading all the plugins in your use statement. If Test::Stream has already finished loading then the callback will be run immedietly.

$bool = Test::Stream::Sync->loaded
Test::Stream::Sync->loaded($true)
    Without arguments this will simply return the boolean value of the loaded flag. If Test::Stream has finished loading this will be true, otherwise false. If a true value is provided as an argument then this will set the flag to true, and run all "post_load" callbacks. The second form should ONLY ever be used in Test::Stream or alternative loader modules.

MAGIC
This package has an END block. This END block is responsible for setting the exit code based on the test results. This end block also calls the hooks that can be added to this package.

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

MAINTAINERS

Chad Granum <exodist@cpan.org>

AUTHORS

Chad Granum <exodist@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/