| 1 | package Test2::Hub::Subtest; | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | |||
| 5 | our $VERSION = '1.302073'; | ||
| 6 | |||
| 7 | |||
| 8 | BEGIN { require Test2::Hub; our @ISA = qw(Test2::Hub) } | ||
| 9 | use Test2::Util::HashBase qw/nested bailed_out exit_code manual_skip_all id/; | ||
| 10 | use Test2::Util qw/get_tid/; | ||
| 11 | |||
| 12 | my $ID = 1; | ||
| 13 | sub init { | ||
| 14 | my $self = shift; | ||
| 15 | $self->SUPER::init(@_); | ||
| 16 | $self->{+ID} ||= join "-", $$, get_tid, $ID++; | ||
| 17 | } | ||
| 18 | |||
| 19 | sub is_subtest { 1 } | ||
| 20 | |||
| 21 | sub process { | ||
| 22 | my $self = shift; | ||
| 23 | my ($e) = @_; | ||
| 24 | $e->set_nested($self->nested); | ||
| 25 | $e->set_in_subtest($self->{+ID}); | ||
| 26 | $self->set_bailed_out($e) if $e->isa('Test2::Event::Bail'); | ||
| 27 | $self->SUPER::process($e); | ||
| 28 | } | ||
| 29 | |||
| 30 | sub send { | ||
| 31 | my $self = shift; | ||
| 32 | my ($e) = @_; | ||
| 33 | |||
| 34 | my $out = $self->SUPER::send($e); | ||
| 35 | |||
| 36 | return $out if $self->{+MANUAL_SKIP_ALL}; | ||
| 37 | return $out unless $e->isa('Test2::Event::Plan') | ||
| 38 | && $e->directive eq 'SKIP' | ||
| 39 | && ($e->trace->pid != $self->pid || $e->trace->tid != $self->tid); | ||
| 40 | |||
| 41 | no warnings 'exiting'; | ||
| 42 | last T2_SUBTEST_WRAPPER; | ||
| 43 | } | ||
| 44 | |||
| 45 | sub terminate { | ||
| 46 | my $self = shift; | ||
| 47 | my ($code, $e) = @_; | ||
| 48 | $self->set_exit_code($code); | ||
| 49 | |||
| 50 | return if $self->{+MANUAL_SKIP_ALL}; | ||
| 51 | return if $e->isa('Test2::Event::Plan') | ||
| 52 | && $e->directive eq 'SKIP' | ||
| 53 | && ($e->trace->pid != $$ || $e->trace->tid != get_tid); | ||
| 54 | |||
| 55 | no warnings 'exiting'; | ||
| 56 | last T2_SUBTEST_WRAPPER; | ||
| 57 | } | ||
| 58 | |||
| 59 | 1; | ||
| 60 | |||
| 61 | __END__ |