<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package Test2::Hub;
use strict;
use warnings;

our $VERSION = '1.302199';


use Carp qw/carp croak confess/;
use Test2::Util qw/get_tid gen_uid/;

use Scalar::Util qw/weaken/;
use List::Util qw/first/;

use Test2::Util::ExternalMeta qw/meta get_meta set_meta delete_meta/;
use Test2::Util::HashBase qw{
    pid tid hid ipc
    nested buffered
    no_ending
    _filters
    _pre_filters
    _listeners
    _follow_ups
    _formatter
    _context_acquire
    _context_init
    _context_release

    uuid
    active
    count
    failed
    ended
    bailed_out
    _passing
    _plan
    skip_reason
};

my $UUID_VIA;

sub init {
    my $self = shift;

    $self-&gt;{+PID} = $$;
    $self-&gt;{+TID} = get_tid();
    $self-&gt;{+HID} = gen_uid();

    $UUID_VIA ||= Test2::API::_add_uuid_via_ref();
    $self-&gt;{+UUID} = ${$UUID_VIA}-&gt;('hub') if $$UUID_VIA;

    $self-&gt;{+NESTED}   = 0 unless defined $self-&gt;{+NESTED};
    $self-&gt;{+BUFFERED} = 0 unless defined $self-&gt;{+BUFFERED};

    $self-&gt;{+COUNT}    = 0;
    $self-&gt;{+FAILED}   = 0;
    $self-&gt;{+_PASSING} = 1;

    if (my $formatter = delete $self-&gt;{formatter}) {
        $self-&gt;format($formatter);
    }

    if (my $ipc = $self-&gt;{+IPC}) {
        $ipc-&gt;add_hub($self-&gt;{+HID});
    }
}

sub is_subtest { 0 }

sub _tb_reset {
    my $self = shift;

    # Nothing to do
    return if $self-&gt;{+PID} == $$ &amp;&amp; $self-&gt;{+TID} == get_tid();

    $self-&gt;{+PID} = $$;
    $self-&gt;{+TID} = get_tid();
    $self-&gt;{+HID} = gen_uid();

    if (my $ipc = $self-&gt;{+IPC}) {
        $ipc-&gt;add_hub($self-&gt;{+HID});
    }
}

sub reset_state {
    my $self = shift;

    $self-&gt;{+COUNT} = 0;
    $self-&gt;{+FAILED} = 0;
    $self-&gt;{+_PASSING} = 1;

    delete $self-&gt;{+_PLAN};
    delete $self-&gt;{+ENDED};
    delete $self-&gt;{+BAILED_OUT};
    delete $self-&gt;{+SKIP_REASON};
}

sub inherit {
    my $self = shift;
    my ($from, %params) = @_;

    $self-&gt;{+NESTED} ||= 0;

    $self-&gt;{+_FORMATTER} = $from-&gt;{+_FORMATTER}
        unless $self-&gt;{+_FORMATTER} || exists($params{formatter});

    if ($from-&gt;{+IPC} &amp;&amp; !$self-&gt;{+IPC} &amp;&amp; !exists($params{ipc})) {
        my $ipc = $from-&gt;{+IPC};
        $self-&gt;{+IPC} = $ipc;
        $ipc-&gt;add_hub($self-&gt;{+HID});
    }

    if (my $ls = $from-&gt;{+_LISTENERS}) {
        push @{$self-&gt;{+_LISTENERS}} =&gt; grep { $_-&gt;{inherit} } @$ls;
    }

    if (my $pfs = $from-&gt;{+_PRE_FILTERS}) {
        push @{$self-&gt;{+_PRE_FILTERS}} =&gt; grep { $_-&gt;{inherit} } @$pfs;
    }

    if (my $fs = $from-&gt;{+_FILTERS}) {
        push @{$self-&gt;{+_FILTERS}} =&gt; grep { $_-&gt;{inherit} } @$fs;
    }
}

sub format {
    my $self = shift;

    my $old = $self-&gt;{+_FORMATTER};
    ($self-&gt;{+_FORMATTER}) = @_ if @_;

    return $old;
}

sub is_local {
    my $self = shift;
    return $$ == $self-&gt;{+PID}
        &amp;&amp; get_tid() == $self-&gt;{+TID};
}

sub listen {
    my $self = shift;
    my ($sub, %params) = @_;

    carp "Useless addition of a listener in a child process or thread!"
        if $$ != $self-&gt;{+PID} || get_tid() != $self-&gt;{+TID};

    croak "listen only takes coderefs for arguments, got '$sub'"
        unless ref $sub &amp;&amp; ref $sub eq 'CODE';

    push @{$self-&gt;{+_LISTENERS}} =&gt; { %params, code =&gt; $sub };

    $sub; # Intentional return.
}

sub unlisten {
    my $self = shift;

    carp "Useless removal of a listener in a child process or thread!"
        if $$ != $self-&gt;{+PID} || get_tid() != $self-&gt;{+TID};

    my %subs = map {$_ =&gt; $_} @_;

    @{$self-&gt;{+_LISTENERS}} = grep { !$subs{$_-&gt;{code}} } @{$self-&gt;{+_LISTENERS}};
}

sub filter {
    my $self = shift;
    my ($sub, %params) = @_;

    carp "Useless addition of a filter in a child process or thread!"
        if $$ != $self-&gt;{+PID} || get_tid() != $self-&gt;{+TID};

    croak "filter only takes coderefs for arguments, got '$sub'"
        unless ref $sub &amp;&amp; ref $sub eq 'CODE';

    push @{$self-&gt;{+_FILTERS}} =&gt; { %params, code =&gt; $sub };

    $sub; # Intentional Return
}

sub unfilter {
    my $self = shift;
    carp "Useless removal of a filter in a child process or thread!"
        if $$ != $self-&gt;{+PID} || get_tid() != $self-&gt;{+TID};
    my %subs = map {$_ =&gt; $_} @_;
    @{$self-&gt;{+_FILTERS}} = grep { !$subs{$_-&gt;{code}} } @{$self-&gt;{+_FILTERS}};
}

sub pre_filter {
    my $self = shift;
    my ($sub, %params) = @_;

    croak "pre_filter only takes coderefs for arguments, got '$sub'"
        unless ref $sub &amp;&amp; ref $sub eq 'CODE';

    push @{$self-&gt;{+_PRE_FILTERS}} =&gt; { %params, code =&gt; $sub };

    $sub; # Intentional Return
}

sub pre_unfilter {
    my $self = shift;
    my %subs = map {$_ =&gt; $_} @_;
    @{$self-&gt;{+_PRE_FILTERS}} = grep { !$subs{$_-&gt;{code}} } @{$self-&gt;{+_PRE_FILTERS}};
}

sub follow_up {
    my $self = shift;
    my ($sub) = @_;

    carp "Useless addition of a follow-up in a child process or thread!"
        if $$ != $self-&gt;{+PID} || get_tid() != $self-&gt;{+TID};

    croak "follow_up only takes coderefs for arguments, got '$sub'"
        unless ref $sub &amp;&amp; ref $sub eq 'CODE';

    push @{$self-&gt;{+_FOLLOW_UPS}} =&gt; $sub;
}

*add_context_aquire = \&amp;add_context_acquire;
sub add_context_acquire {
    my $self = shift;
    my ($sub) = @_;

    croak "add_context_acquire only takes coderefs for arguments, got '$sub'"
        unless ref $sub &amp;&amp; ref $sub eq 'CODE';

    push @{$self-&gt;{+_CONTEXT_ACQUIRE}} =&gt; $sub;

    $sub; # Intentional return.
}

*remove_context_aquire = \&amp;remove_context_acquire;
sub remove_context_acquire {
    my $self = shift;
    my %subs = map {$_ =&gt; $_} @_;
    @{$self-&gt;{+_CONTEXT_ACQUIRE}} = grep { !$subs{$_} == $_ } @{$self-&gt;{+_CONTEXT_ACQUIRE}};
}

sub add_context_init {
    my $self = shift;
    my ($sub) = @_;

    croak "add_context_init only takes coderefs for arguments, got '$sub'"
        unless ref $sub &amp;&amp; ref $sub eq 'CODE';

    push @{$self-&gt;{+_CONTEXT_INIT}} =&gt; $sub;

    $sub; # Intentional return.
}

sub remove_context_init {
    my $self = shift;
    my %subs = map {$_ =&gt; $_} @_;
    @{$self-&gt;{+_CONTEXT_INIT}} = grep { !$subs{$_} == $_ } @{$self-&gt;{+_CONTEXT_INIT}};
}

sub add_context_release {
    my $self = shift;
    my ($sub) = @_;

    croak "add_context_release only takes coderefs for arguments, got '$sub'"
        unless ref $sub &amp;&amp; ref $sub eq 'CODE';

    push @{$self-&gt;{+_CONTEXT_RELEASE}} =&gt; $sub;

    $sub; # Intentional return.
}

sub remove_context_release {
    my $self = shift;
    my %subs = map {$_ =&gt; $_} @_;
    @{$self-&gt;{+_CONTEXT_RELEASE}} = grep { !$subs{$_} == $_ } @{$self-&gt;{+_CONTEXT_RELEASE}};
}

sub send {
    my $self = shift;
    my ($e) = @_;

    $e-&gt;eid;

    $e-&gt;add_hub(
        {
            details =&gt; ref($self),

            buffered =&gt; $self-&gt;{+BUFFERED},
            hid      =&gt; $self-&gt;{+HID},
            nested   =&gt; $self-&gt;{+NESTED},
            pid      =&gt; $self-&gt;{+PID},
            tid      =&gt; $self-&gt;{+TID},
            uuid     =&gt; $self-&gt;{+UUID},

            ipc =&gt; $self-&gt;{+IPC} ? 1 : 0,
        }
    );

    $e-&gt;set_uuid(${$UUID_VIA}-&gt;('event')) if $$UUID_VIA;

    if ($self-&gt;{+_PRE_FILTERS}) {
        for (@{$self-&gt;{+_PRE_FILTERS}}) {
            $e = $_-&gt;{code}-&gt;($self, $e);
            return unless $e;
        }
    }

    my $ipc = $self-&gt;{+IPC} || return $self-&gt;process($e);

    if($e-&gt;global) {
        $ipc-&gt;send($self-&gt;{+HID}, $e, 'GLOBAL');
        return $self-&gt;process($e);
    }

    return $ipc-&gt;send($self-&gt;{+HID}, $e)
        if $$ != $self-&gt;{+PID} || get_tid() != $self-&gt;{+TID};

    $self-&gt;process($e);
}

sub process {
    my $self = shift;
    my ($e) = @_;

    if ($self-&gt;{+_FILTERS}) {
        for (@{$self-&gt;{+_FILTERS}}) {
            $e = $_-&gt;{code}-&gt;($self, $e);
            return unless $e;
        }
    }

    # Optimize the most common case
    my $type = ref($e);
    if ($type eq 'Test2::Event::Pass' || ($type eq 'Test2::Event::Ok' &amp;&amp; $e-&gt;{pass})) {
        my $count = ++($self-&gt;{+COUNT});
        $self-&gt;{+_FORMATTER}-&gt;write($e, $count) if $self-&gt;{+_FORMATTER};

        if ($self-&gt;{+_LISTENERS}) {
            $_-&gt;{code}-&gt;($self, $e, $count) for @{$self-&gt;{+_LISTENERS}};
        }

        return $e;
    }

    my $f = $e-&gt;facet_data;

    my $fail = 0;
    $fail = 1 if $f-&gt;{assert} &amp;&amp; !$f-&gt;{assert}-&gt;{pass};
    $fail = 1 if $f-&gt;{errors} &amp;&amp; grep { $_-&gt;{fail} } @{$f-&gt;{errors}};
    $fail = 0 if $f-&gt;{amnesty};

    $self-&gt;{+COUNT}++ if $f-&gt;{assert};
    $self-&gt;{+FAILED}++ if $fail &amp;&amp; $f-&gt;{assert};
    $self-&gt;{+_PASSING} = 0 if $fail;

    my $code = $f-&gt;{control} ? $f-&gt;{control}-&gt;{terminate} : undef;
    my $count = $self-&gt;{+COUNT};

    if (my $plan = $f-&gt;{plan}) {
        if ($plan-&gt;{skip}) {
            $self-&gt;plan('SKIP');
            $self-&gt;set_skip_reason($plan-&gt;{details} || 1);
            $code ||= 0;
        }
        elsif ($plan-&gt;{none}) {
            $self-&gt;plan('NO PLAN');
        }
        else {
            $self-&gt;plan($plan-&gt;{count});
        }
    }

    $e-&gt;callback($self) if $f-&gt;{control} &amp;&amp; $f-&gt;{control}-&gt;{has_callback};

    $self-&gt;{+_FORMATTER}-&gt;write($e, $count, $f) if $self-&gt;{+_FORMATTER};

    if ($self-&gt;{+_LISTENERS}) {
        $_-&gt;{code}-&gt;($self, $e, $count, $f) for @{$self-&gt;{+_LISTENERS}};
    }

    if ($f-&gt;{control} &amp;&amp; $f-&gt;{control}-&gt;{halt}) {
        $code ||= 255;
        $self-&gt;set_bailed_out($e);
    }

    if (defined $code) {
        $self-&gt;{+_FORMATTER}-&gt;terminate($e, $f) if $self-&gt;{+_FORMATTER};
        $self-&gt;terminate($code, $e, $f);
    }

    return $e;
}

sub terminate {
    my $self = shift;
    my ($code) = @_;
    exit($code);
}

sub cull {
    my $self = shift;

    my $ipc = $self-&gt;{+IPC} || return;
    return if $self-&gt;{+PID} != $$ || $self-&gt;{+TID} != get_tid();

    # No need to do IPC checks on culled events
    $self-&gt;process($_) for $ipc-&gt;cull($self-&gt;{+HID});
}

sub finalize {
    my $self = shift;
    my ($trace, $do_plan) = @_;

    $self-&gt;cull();

    my $plan   = $self-&gt;{+_PLAN};
    my $count  = $self-&gt;{+COUNT};
    my $failed = $self-&gt;{+FAILED};
    my $active = $self-&gt;{+ACTIVE};

    # return if NOTHING was done.
    unless ($active || $do_plan || defined($plan) || $count || $failed) {
        $self-&gt;{+_FORMATTER}-&gt;finalize($plan, $count, $failed, 0, $self-&gt;is_subtest) if $self-&gt;{+_FORMATTER};
        return;
    }

    unless ($self-&gt;{+ENDED}) {
        if ($self-&gt;{+_FOLLOW_UPS}) {
            $_-&gt;($trace, $self) for reverse @{$self-&gt;{+_FOLLOW_UPS}};
        }

        # These need to be refreshed now
        $plan   = $self-&gt;{+_PLAN};
        $count  = $self-&gt;{+COUNT};
        $failed = $self-&gt;{+FAILED};

        if ((defined($plan) &amp;&amp; $plan eq 'NO PLAN') || ($do_plan &amp;&amp; !defined($plan))) {
            $self-&gt;send(
                Test2::Event::Plan-&gt;new(
                    trace =&gt; $trace,
                    max =&gt; $count,
                )
            );
        }
        $plan = $self-&gt;{+_PLAN};
    }

    my $frame = $trace-&gt;frame;
    if($self-&gt;{+ENDED}) {
        my (undef, $ffile, $fline) = @{$self-&gt;{+ENDED}};
        my (undef, $sfile, $sline) = @$frame;

        die &lt;&lt;"        EOT"
Test already ended!
First End:  $ffile line $fline
Second End: $sfile line $sline
        EOT
    }

    $self-&gt;{+ENDED} = $frame;
    my $pass = $self-&gt;is_passing(); # Generate the final boolean.

    $self-&gt;{+_FORMATTER}-&gt;finalize($plan, $count, $failed, $pass, $self-&gt;is_subtest) if $self-&gt;{+_FORMATTER};

    return $pass;
}

sub is_passing {
    my $self = shift;

    ($self-&gt;{+_PASSING}) = @_ if @_;

    # If we already failed just return 0.
    my $pass = $self-&gt;{+_PASSING} or return 0;
    return $self-&gt;{+_PASSING} = 0 if $self-&gt;{+FAILED};

    my $count = $self-&gt;{+COUNT};
    my $ended = $self-&gt;{+ENDED};
    my $plan = $self-&gt;{+_PLAN};

    return $pass if !$count &amp;&amp; $plan &amp;&amp; $plan =~ m/^SKIP$/;

    return $self-&gt;{+_PASSING} = 0
        if $ended &amp;&amp; (!$count || !$plan);

    return $pass unless $plan &amp;&amp; $plan =~ m/^\d+$/;

    if ($ended) {
        return $self-&gt;{+_PASSING} = 0 if $count != $plan;
    }
    else {
        return $self-&gt;{+_PASSING} = 0 if $count &gt; $plan;
    }

    return $pass;
}

sub plan {
    my $self = shift;

    return $self-&gt;{+_PLAN} unless @_;

    my ($plan) = @_;

    confess "You cannot unset the plan"
        unless defined $plan;

    confess "You cannot change the plan"
        if $self-&gt;{+_PLAN} &amp;&amp; $self-&gt;{+_PLAN} !~ m/^NO PLAN$/;

    confess "'$plan' is not a valid plan! Plan must be an integer greater than 0, 'NO PLAN', or 'SKIP'"
        unless $plan =~ m/^(\d+|NO PLAN|SKIP)$/;

    $self-&gt;{+_PLAN} = $plan;
}

sub check_plan {
    my $self = shift;

    return undef unless $self-&gt;{+ENDED};
    my $plan = $self-&gt;{+_PLAN} || return undef;

    return 1 if $plan !~ m/^\d+$/;

    return 1 if $plan == $self-&gt;{+COUNT};
    return 0;
}

sub DESTROY {
    my $self = shift;
    my $ipc = $self-&gt;{+IPC} || return;
    return unless $$ == $self-&gt;{+PID};
    return unless get_tid() == $self-&gt;{+TID};
    $ipc-&gt;drop_hub($self-&gt;{+HID});
}

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

Test2::Hub - The conduit through which all events flow.

=head1 SYNOPSIS

    use Test2::Hub;

    my $hub = Test2::Hub-&gt;new();
    $hub-&gt;send(...);

=head1 DESCRIPTION

The hub is the place where all events get processed and handed off to the
formatter. The hub also tracks test state, and provides several hooks into the
event pipeline.

=head1 COMMON TASKS

=head2 SENDING EVENTS

    $hub-&gt;send($event)

The C&lt;send()&gt; method is used to issue an event to the hub. This method will
handle thread/fork sync, filters, listeners, TAP output, etc.

=head2 ALTERING OR REMOVING EVENTS

You can use either C&lt;filter()&gt; or C&lt;pre_filter()&gt;, depending on your
needs. Both have identical syntax, so only C&lt;filter()&gt; is shown here.

    $hub-&gt;filter(sub {
        my ($hub, $event) = @_;

        my $action = get_action($event);

        # No action should be taken
        return $event if $action eq 'none';

        # You want your filter to remove the event
        return undef if $action eq 'delete';

        if ($action eq 'do_it') {
            my $new_event = copy_event($event);
            ... Change your copy of the event ...
            return $new_event;
        }

        die "Should not happen";
    });

By default, filters are not inherited by child hubs. That means if you start a
subtest, the subtest will not inherit the filter. You can change this behavior
with the C&lt;inherit&gt; parameter:

    $hub-&gt;filter(sub { ... }, inherit =&gt; 1);

=head2 LISTENING FOR EVENTS

    $hub-&gt;listen(sub {
        my ($hub, $event, $number) = @_;

        ... do whatever you want with the event ...

        # return is ignored
    });

By default listeners are not inherited by child hubs. That means if you start a
subtest, the subtest will not inherit the listener. You can change this behavior
with the C&lt;inherit&gt; parameter:

    $hub-&gt;listen(sub { ... }, inherit =&gt; 1);


=head2 POST-TEST BEHAVIORS

    $hub-&gt;follow_up(sub {
        my ($trace, $hub) = @_;

        ... do whatever you need to ...

        # Return is ignored
    });

follow_up subs are called only once, either when done_testing is called, or in
an END block.

=head2 SETTING THE FORMATTER

By default an instance of L&lt;Test2::Formatter::TAP&gt; is created and used.

    my $old = $hub-&gt;format(My::Formatter-&gt;new);

Setting the formatter will REPLACE any existing formatter. You may set the
formatter to undef to prevent output. The old formatter will be returned if one
was already set. Only one formatter is allowed at a time.

=head1 METHODS

=over 4

=item $hub-&gt;send($event)

This is where all events enter the hub for processing.

=item $hub-&gt;process($event)

This is called by send after it does any IPC handling. You can use this to
bypass the IPC process, but in general you should avoid using this.

=item $old = $hub-&gt;format($formatter)

Replace the existing formatter instance with a new one. Formatters must be
objects that implement a C&lt;&lt; $formatter-&gt;write($event) &gt;&gt; method.

=item $sub = $hub-&gt;listen(sub { ... }, %optional_params)

You can use this to record all events AFTER they have been sent to the
formatter. No changes made here will be meaningful, except possibly to other
listeners.

    $hub-&gt;listen(sub {
        my ($hub, $event, $number) = @_;

        ... do whatever you want with the event ...

        # return is ignored
    });

Normally listeners are not inherited by child hubs such as subtests. You can
add the C&lt;&lt; inherit =&gt; 1 &gt;&gt; parameter to allow a listener to be inherited.

=item $hub-&gt;unlisten($sub)

You can use this to remove a listen callback. You must pass in the coderef
returned by the C&lt;listen()&gt; method.

=item $sub = $hub-&gt;filter(sub { ... }, %optional_params)

=item $sub = $hub-&gt;pre_filter(sub { ... }, %optional_params)

These can be used to add filters. Filters can modify, replace, or remove events
before anything else can see them.

    $hub-&gt;filter(
        sub {
            my ($hub, $event) = @_;

            return $event;    # No Changes
            return;           # Remove the event

            # Or you can modify an event before returning it.
            $event-&gt;modify;
            return $event;
        }
    );

If you are not using threads, forking, or IPC then the only difference between
a C&lt;filter&gt; and a C&lt;pre_filter&gt; is that C&lt;pre_filter&gt; subs run first. When you
are using threads, forking, or IPC, pre_filters happen to events before they
are sent to their destination proc/thread, ordinary filters happen only in the
destination hub/thread.

You cannot add a regular filter to a hub if the hub was created in another
process or thread. You can always add a pre_filter.

=item $hub-&gt;unfilter($sub)

=item $hub-&gt;pre_unfilter($sub)

These can be used to remove filters and pre_filters. The C&lt;$sub&gt; argument is
the reference returned by C&lt;filter()&gt; or C&lt;pre_filter()&gt;.

=item $hub-&gt;follow_op(sub { ... })

Use this to add behaviors that are called just before the hub is finalized. The
only argument to your codeblock will be a L&lt;Test2::EventFacet::Trace&gt; instance.

    $hub-&gt;follow_up(sub {
        my ($trace, $hub) = @_;

        ... do whatever you need to ...

        # Return is ignored
    });

follow_up subs are called only once, ether when done_testing is called, or in
an END block.

=item $sub = $hub-&gt;add_context_acquire(sub { ... });

Add a callback that will be called every time someone tries to acquire a
context. It gets a single argument, a reference of the hash of parameters
being used the construct the context. This is your chance to change the
parameters by directly altering the hash.

    test2_add_callback_context_acquire(sub {
        my $params = shift;
        $params-&gt;{level}++;
    });

This is a very scary API function. Please do not use this unless you need to.
This is here for L&lt;Test::Builder&gt; and backwards compatibility. This has you
directly manipulate the hash instead of returning a new one for performance
reasons.

B&lt;Note&gt; Using this hook could have a huge performance impact.

The coderef you provide is returned and can be used to remove the hook later.

=item $hub-&gt;remove_context_acquire($sub);

This can be used to remove a context acquire hook.

=item $sub = $hub-&gt;add_context_init(sub { ... });

This allows you to add callbacks that will trigger every time a new context is
created for the hub. The only argument to the sub will be the
L&lt;Test2::API::Context&gt; instance that was created.

B&lt;Note&gt; Using this hook could have a huge performance impact.

The coderef you provide is returned and can be used to remove the hook later.

=item $hub-&gt;remove_context_init($sub);

This can be used to remove a context init hook.

=item $sub = $hub-&gt;add_context_release(sub { ... });

This allows you to add callbacks that will trigger every time a context for
this hub is released. The only argument to the sub will be the
L&lt;Test2::API::Context&gt; instance that was released. These will run in reverse
order.

B&lt;Note&gt; Using this hook could have a huge performance impact.

The coderef you provide is returned and can be used to remove the hook later.

=item $hub-&gt;remove_context_release($sub);

This can be used to remove a context release hook.

=item $hub-&gt;cull()

Cull any IPC events (and process them).

=item $pid = $hub-&gt;pid()

Get the process id under which the hub was created.

=item $tid = $hub-&gt;tid()

Get the thread id under which the hub was created.

=item $hud = $hub-&gt;hid()

Get the identifier string of the hub.

=item $uuid = $hub-&gt;uuid()

If UUID tagging is enabled (see L&lt;Test2::API&gt;) then the hub will have a UUID.

=item $ipc = $hub-&gt;ipc()

Get the IPC object used by the hub.

=item $hub-&gt;set_no_ending($bool)

=item $bool = $hub-&gt;no_ending

This can be used to disable auto-ending behavior for a hub. The auto-ending
behavior is triggered by an end block and is used to cull IPC events, and
output the final plan if the plan was 'NO PLAN'.

=item $bool = $hub-&gt;active

=item $hub-&gt;set_active($bool)

These are used to get/set the 'active' attribute. When true this attribute will
force C&lt;&lt; hub-&gt;finalize() &gt;&gt; to take action even if there is no plan, and no
tests have been run. This flag is useful for plugins that add follow-up
behaviors that need to run even if no events are seen.

=back

=head2 STATE METHODS

=over 4

=item $hub-&gt;reset_state()

Reset all state to the start. This sets the test count to 0, clears the plan,
removes the failures, etc.

=item $num = $hub-&gt;count

Get the number of tests that have been run.

=item $num = $hub-&gt;failed

Get the number of failures (Not all failures come from a test fail, so this
number can be larger than the count).

=item $bool = $hub-&gt;ended

True if the testing has ended. This MAY return the stack frame of the tool that
ended the test, but that is not guaranteed.

=item $bool = $hub-&gt;is_passing

=item $hub-&gt;is_passing($bool)

Check if the overall test run is a failure. Can also be used to set the
pass/fail status.

=item $hub-&gt;plan($plan)

=item $plan = $hub-&gt;plan

Get or set the plan. The plan must be an integer larger than 0, the string
'NO PLAN', or the string 'SKIP'.

=item $bool = $hub-&gt;check_plan

Check if the plan and counts match, but only if the tests have ended. If tests
have not ended this will return undef, otherwise it will be a true/false.

=back

=head1 THIRD PARTY META-DATA

This object consumes L&lt;Test2::Util::ExternalMeta&gt; which provides a consistent
way for you to attach meta-data to instances of this class. This is useful for
tools, plugins, and other extensions.

=head1 SOURCE

The source code repository for Test2 can be found at
L&lt;https://github.com/Test-More/test-more/&gt;.

=head1 MAINTAINERS

=over 4

=item Chad Granum E&lt;lt&gt;exodist@cpan.orgE&lt;gt&gt;

=back

=head1 AUTHORS

=over 4

=item Chad Granum E&lt;lt&gt;exodist@cpan.orgE&lt;gt&gt;

=back

=head1 COPYRIGHT

Copyright 2020 Chad Granum E&lt;lt&gt;exodist@cpan.orgE&lt;gt&gt;.

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

See L&lt;https://dev.perl.org/licenses/&gt;

=cut
</pre></body></html>