1package Test2::AsyncSubtest::Hub; 2use strict; 3use warnings; 4 5our $VERSION = '0.000162'; 6 7use base 'Test2::Hub::Subtest'; 8use Test2::Util::HashBase qw/ast_ids ast/; 9use Test2::Util qw/get_tid/; 10 11sub init { 12 my $self = shift; 13 14 $self->SUPER::init(); 15 16 if (my $format = $self->format) { 17 my $hide = $format->can('hide_buffered') ? $format->hide_buffered : 1; 18 $self->format(undef) if $hide; 19 } 20} 21 22sub inherit { 23 my $self = shift; 24 my ($from, %params) = @_; 25 26 if (my $ls = $from->{+_LISTENERS}) { 27 push @{$self->{+_LISTENERS}} => grep { $_->{inherit} } @$ls; 28 } 29 30 if (my $pfs = $from->{+_PRE_FILTERS}) { 31 push @{$self->{+_PRE_FILTERS}} => grep { $_->{inherit} } @$pfs; 32 } 33 34 if (my $fs = $from->{+_FILTERS}) { 35 push @{$self->{+_FILTERS}} => grep { $_->{inherit} } @$fs; 36 } 37} 38 39sub send { 40 my $self = shift; 41 my ($e) = @_; 42 43 if (my $ast = $self->ast) { 44 if ($$ != $ast->pid || get_tid != $ast->tid) { 45 if (my $plan = $e->facet_data->{plan}) { 46 unless ($plan->{skip}) { 47 my $trace = $e->facet_data->{trace}; 48 bless($trace, 'Test2::EventFacet::Trace'); 49 $trace->alert("A plan should not be set inside an async-subtest (did you call done_testing()?)"); 50 return; 51 } 52 } 53 } 54 } 55 56 return $self->SUPER::send($e); 57} 58 591; 60 61__END__ 62 63=pod 64 65=encoding UTF-8 66 67=head1 NAME 68 69Test2::AsyncSubtest::Hub - Hub used by async subtests. 70 71=head1 DESCRIPTION 72 73This is a subclass of L<Test2::Hub::Subtest> used for async subtests. 74 75=head1 SYNOPSIS 76 77You should not use this directly. 78 79=head1 METHODS 80 81=over 4 82 83=item $ast = $hub->ast 84 85Get the L<Test2::AsyncSubtest> object to which this hub is bound. 86 87=back 88 89=head1 SOURCE 90 91The source code repository for Test2-AsyncSubtest can be found at 92F<https://github.com/Test-More/Test2-Suite/>. 93 94=head1 MAINTAINERS 95 96=over 4 97 98=item Chad Granum E<lt>exodist@cpan.orgE<gt> 99 100=back 101 102=head1 AUTHORS 103 104=over 4 105 106=item Chad Granum E<lt>exodist@cpan.orgE<gt> 107 108=back 109 110=head1 COPYRIGHT 111 112Copyright 2018 Chad Granum E<lt>exodist7@gmail.comE<gt>. 113 114This program is free software; you can redistribute it and/or 115modify it under the same terms as Perl itself. 116 117See F<http://dev.perl.org/licenses/> 118 119=cut 120