package Test::Stream::Plugin::IPC;
use strict;
use warnings;

use Test::Stream::IPC();

use Test::Stream::Context qw/context/;
use Test::Stream::Util qw/pkg_to_file/;
use Carp qw/croak confess/;

use Test::Stream::Plugin qw/import/;

sub load_ts_plugin {
    my $class = shift;
    my $caller = shift;

    my @drivers;
    my %params;

    for my $arg (@_) {
        if ($arg =~ m/^-(.*)$/) {
        elsif ($arg =~ m/^\+(.+)$/) {
            push @drivers => $1;
        else {
            push @drivers => "Test::Stream::IPC::$arg";

    for my $driver (@drivers) {
        my $file = pkg_to_file($driver);
        unless(eval { require $file; 1 }) {
            my $error = $@;
            die $error unless $error =~ m/^Can't locate/;

    Test::Stream::IPC->enable_polling if delete $params{poll};

    if (delete $params{cull}) {
        no strict 'refs';
        *{"$caller->[0]\::cull"} = \&cull

    if (my @bad = keys %params) {
        confess "Invalid parameters: " . join ', ', map { "'-$_'" } @bad;

sub cull {
    my $ctx = context();




=encoding UTF-8

=head1 NAME

Test::Stream::Plugin::IPC - Plugin to load and configure IPC support.


B<This distribution is deprecated> in favor of L<Test2>, L<Test2::Suite>, and

See L<Test::Stream::Manual::ToTest2> for a conversion guide.


The L<Test::Stream> IPC layer provided by L<Test::Stream::IPC> is responsible
for sending events between threads and processes. This is necessary for any
test files that fork or use threads. This plugin provides an interface to
loading and using the IPC layer.


    use Test::Stream qw/IPC/;

You may wish to enable polling, which will pull in results frequently, by
default results from other threads and processes all come it at once at the end
of testing.

    use Test::Stream IPC => [qw/-poll/];

You can also import the C<cull()> function that can be used to pull results in
on demand.

    use Test::Stream IPC => [qw/-cull/];


You can also specify a list of drivers to try in order:

    use Test::Stream IPC => [

=head1 SOURCE

The source code repository for Test::Stream can be found at


=over 4

=item Chad Granum E<lt>exodist@cpan.orgE<gt>


=head1 AUTHORS

=over 4

=item Chad Granum E<lt>exodist@cpan.orgE<gt>



Copyright 2015 Chad Granum E<lt>exodist7@gmail.comE<gt>.

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

See F<>