blib/lib/Test2/IPC/Driver.pm

filter: Statementstmt 100% 40 / 40 Branchbran 80.0% 8 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 12 / 12 Podpod 50.0% 2 / 4 totaltotal 93.9% 62 / 66 CC 6 SCAR 7.2
CC
6
Cov
96%
abort
4.0
import
3.0
BEGIN
1.0
CRAP 2.1
« blib/lib/Test2/Tools/Subtest.pm ↑ Summary blib/lib/Test2/AsyncSubtest/Formatter.pm »
1 package Test2::IPC::Driver;
2 102 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 102 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 102 our $VERSION = '1.302226';
6  
7  
8 102 ▶use Carp qw/confess/;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 102 ▶use Test2::Util::HashBase qw{no_fatal no_bail};
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 102 ▶use Test2::API qw/test2_ipc_add_driver/;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 102 my %ADDED;
14 7 ▶sub import {
Subroutine import: called CC=3 SCAR=11.0
15 7 my $class = shift;
16 7 ▶ return if $class eq __PACKAGE__;
Branch: 1 branch
BranchTrueFalseTotal
if $class eq __PACKAGE__ 0 7 7
17 7 ▶ return if $ADDED{$class}++;
Branch: 1 branch
BranchTrueFalseTotal
if $ADDED{$class}++ 3 4 7
18 4 test2_ipc_add_driver($class);
19 }
20  
21 2121 ▶sub pending { -1 }
Subroutine pending: called CC=1 SCAR=0.0
Pod undocumented
22 219 ▶sub set_pending { -1 }
Subroutine set_pending: called CC=1 SCAR=0.0
Pod undocumented
23  
24 102 for my $meth (qw/send cull add_hub drop_hub waiting is_viable/) {
25 102 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
26 6 ▶ *$meth = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
27 6 my $thing = shift;
28 6 confess "'$thing' did not define the required method '$meth'."
29 612 };
30 }
31  
32 # Print the error and call exit. We are not using 'die' cause this is a
33 # catastrophic error that should never be caught. If we get here it
34 # means some serious shit has happened in a child process, the only way
35 # to inform the parent may be to exit false.
36  
37 13 ▶sub abort {
Subroutine abort: called CC=4 SCAR=13.9
Pod documented
38 13 my $self = shift;
39 13 chomp(my ($msg) = @_);
40  
41 13 ▶ $self->driver_abort($msg) if $self->can('driver_abort');
Branch: 1 branch
BranchTrueFalseTotal
if $self->can("driver_abort") 11 2 13
42  
43 13 print STDERR "IPC Fatal Error: $msg\n";
44 13 ▶ print STDOUT "Bail out! IPC Fatal Error: $msg\n" unless $self->no_bail;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->no_bail 2 11 13
45  
46 13 ▶ CORE::exit(255) unless $self->no_fatal;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->no_fatal 0 13 13
47 }
48  
49 6 ▶sub abort_trace {
Subroutine abort_trace: called CC=1 SCAR=0.0
Pod documented
50 6 my $self = shift;
51 6 my ($msg) = @_;
52 # Older versions of Carp do not export longmess() function, so it needs to be called with package name
53 6 $self->abort(Carp::longmess($msg));
54 }
55  
56 102 1;
57  
58 __END__
« blib/lib/Test2/Tools/Subtest.pm ↑ Summary blib/lib/Test2/AsyncSubtest/Formatter.pm »