Interceptor.pm revision 1.1.1.2
1package Test2::Hub::Interceptor;
2use strict;
3use warnings;
4
5our $VERSION = '1.302162';
6
7
8use Test2::Hub::Interceptor::Terminator();
9
10BEGIN { require Test2::Hub; our @ISA = qw(Test2::Hub) }
11use Test2::Util::HashBase;
12
13sub init {
14    my $self = shift;
15    $self->SUPER::init();
16    $self->{+NESTED} = 0;
17}
18
19sub inherit {
20    my $self = shift;
21    my ($from, %params) = @_;
22
23    $self->{+NESTED} = 0;
24
25    if ($from->{+IPC} && !$self->{+IPC} && !exists($params{ipc})) {
26        my $ipc = $from->{+IPC};
27        $self->{+IPC} = $ipc;
28        $ipc->add_hub($self->{+HID});
29    }
30}
31
32sub terminate {
33    my $self = shift;
34    my ($code) = @_;
35
36    eval {
37        no warnings 'exiting';
38        last T2_SUBTEST_WRAPPER;
39    };
40    my $err = $@;
41
42    # Fallback
43    die bless(\$err, 'Test2::Hub::Interceptor::Terminator');
44}
45
461;
47
48__END__
49
50=pod
51
52=encoding UTF-8
53
54=head1 NAME
55
56Test2::Hub::Interceptor - Hub used by interceptor to grab results.
57
58=head1 SOURCE
59
60The source code repository for Test2 can be found at
61F<http://github.com/Test-More/test-more/>.
62
63=head1 MAINTAINERS
64
65=over 4
66
67=item Chad Granum E<lt>exodist@cpan.orgE<gt>
68
69=back
70
71=head1 AUTHORS
72
73=over 4
74
75=item Chad Granum E<lt>exodist@cpan.orgE<gt>
76
77=back
78
79=head1 COPYRIGHT
80
81Copyright 2019 Chad Granum E<lt>exodist@cpan.orgE<gt>.
82
83This program is free software; you can redistribute it and/or
84modify it under the same terms as Perl itself.
85
86See F<http://dev.perl.org/licenses/>
87
88=cut
89