File Coverage

blib/lib/Test2/IPC/Driver.pm
Criterion Covered Total %
statement 32 33 96.9
branch 5 6 83.3
condition n/a
subroutine 10 11 90.9
pod 3 3 100.0
total 50 53 94.3


line stmt bran cond sub pod time code
1             package Test2::IPC::Driver;
2 23     23   109 use strict;
  23         23  
  23         547  
3 23     23   71 use warnings;
  23         23  
  23         906  
4              
5             our $VERSION = '0.000043';
6             $VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval)
7              
8 23     23   75 use Carp qw/confess longmess/;
  23         42  
  23         1059  
9 23     23   385 use Test2::Util::HashBase qw{no_fatal};
  23         21  
  23         127  
10              
11 23     23   489 use Test2::API qw/test2_ipc_add_driver/;
  23         35  
  23         2297  
12              
13             my %ADDED;
14             sub import {
15 4     4   25 my $class = shift;
16 4 50       9 return if $class eq __PACKAGE__;
17 4 100       48 return if $ADDED{$class}++;
18 1         3 test2_ipc_add_driver($class);
19             }
20              
21 0     0 1 0 sub use_shm { 0 }
22              
23             for my $meth (qw/send cull add_hub drop_hub waiting is_viable/) {
24 23     23   101 no strict 'refs';
  23         26  
  23         3989  
25             *$meth = sub {
26 6     6   98 my $thing = shift;
27 6         888 confess "'$thing' did not define the required method '$meth'."
28             };
29             }
30              
31             # Print the error and call exit. We are not using 'die' cause this is a
32             # catastophic error that should never be caught. If we get here it
33             # means some serious shit has happened in a child process, the only way
34             # to inform the parent may be to exit false.
35              
36             sub abort {
37 14     14 1 2077 my $self = shift;
38 14         29 chomp(my ($msg) = @_);
39 14         48 print STDERR "IPC Fatal Error: $msg\n";
40 14         29 print STDOUT "not ok - IPC Fatal Error\n";
41              
42 14 100       45 CORE::exit(255) unless $self->no_fatal;
43             }
44              
45             sub abort_trace {
46 4     4 1 21 my $self = shift;
47 4         5 my ($msg) = @_;
48 4         296 $self->abort(longmess($msg));
49             }
50              
51             1;
52              
53             __END__