| 1 | package Net::SSH::Any::Test::Isolated; | ||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 5 | 1 | ▶ | use feature qw(say); | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 6 | 1 | ▶ | use Carp; | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 7 | 1 | ▶ | use Scalar::Util (); | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 8 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 9 | 1 | ▶ | use IPC::Open2 qw(open2); | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||
| 11 | 1 | our $debug; | |||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||
| 13 | 1 | ▶ | use parent qw(Net::SSH::Any::Test::Isolated::_Base); | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 14 | 1 | ▶ | use Net::SSH::Any::URI; | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||
| 17 | 0 | ▶ | sub _default_logger { | ||||||||||||||||||||||
|
Subroutine
_default_logger: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||
| 18 | 0 | my ($fh, $text) = @_; | |||||||||||||||||||||||
| 19 | 0 | print {$fh} $text; | |||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||
| 22 | 13 | ▶ | sub _diag_logger { | ||||||||||||||||||||||
|
Subroutine
_diag_logger: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 23 | 13 | require Test::More; | |||||||||||||||||||||||
| 24 | 13 | Test::More::diag($_[1]); | |||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||
| 27 | 3 | ▶ | sub new { | ||||||||||||||||||||||
|
Subroutine
new: called CC=7 SCAR=21.0
Pod
undocumented
| |||||||||||||||||||||||||
| 28 | 3 | my ($class, %opts) = @_; | |||||||||||||||||||||||
| 29 | 3 | my $self = $class->SUPER::_new('client'); | |||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||
| 31 | 3 | ▶ | my $logger_fh = delete $opts{logger_fh} // \*STDERR; | ||||||||||||||||||||||
|
Condition50%1/2
delete $opts{"logger_fh"} // \*STDERR
MC/DC0%0/1
delete $opts{"logger_fh"} // \*STDERR
delete $opts{"logger_fh"}
Truth table50%1/2
A
A= delete $opts{"logger_fh"}
| |||||||||||||||||||||||||
| 32 | 3 | open my $logger_fh_dup, '>>&', $logger_fh; | |||||||||||||||||||||||
| 33 | 3 | $self->{logger_fh} = $logger_fh_dup; | |||||||||||||||||||||||
| 34 | 3 | ▶ | my $logger = delete $opts{logger} // \&_default_logger; | ||||||||||||||||||||||
|
Condition50%1/2
delete $opts{"logger"} // \&Net::SSH::Any::Test::Isolated::_default_logger
MC/DC0%0/1
delete $opts{"logger"} // \&Net::SSH::Any::Test::Isolated::_default_logger
delete $opts{"logger"}
Truth table50%1/2
A
A= delete $opts{"logger"}
| |||||||||||||||||||||||||
| 35 | 3 | ▶ | unless (ref $logger) { | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 36 | 3 | ▶ | if ($logger eq 'diag') { | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 37 | 3 | $logger = \&_diag_logger; | |||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||
| 39 | else { | ||||||||||||||||||||||||
| 40 | 0 | croak "Bad logger argument '$logger'"; | |||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||
| 43 | 3 | $self->{logger} = $logger; | |||||||||||||||||||||||
| 44 | 3 | ▶ | $self->{perl} = $opts{local_perl_cmd} // $^X // 'perl'; | ||||||||||||||||||||||
|
Condition40%2/5
($opts{"local_perl_cmd"} // $^X) // "perl"
$opts{"local_perl_cmd"} // $^X
MC/DC0%0/2
($opts{"local_perl_cmd"} // $^X) // "perl"
$opts{"local_perl_cmd"}
$^X
Truth table33%1/3
A // B
A= $opts{"local_perl_cmd"}B= $^X
| |||||||||||||||||||||||||
| 45 | 3 | $self->_bootstrap; | |||||||||||||||||||||||
| 46 | 3 | $self->_start(%opts); | |||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||
| 48 | 3 | $self; | |||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||
| 51 | 13 | ▶ | sub _log { | ||||||||||||||||||||||
|
Subroutine
_log: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 52 | 13 | my $self = shift; | |||||||||||||||||||||||
| 53 | 13 | $self->{logger}->($self->{logger_fh}, @_); | |||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||
| 56 | 3 | ▶ | sub _bootstrap { | ||||||||||||||||||||||
|
Subroutine
_bootstrap: called CC=4 SCAR=14.2
| |||||||||||||||||||||||||
| 57 | 3 | my $self = shift; | |||||||||||||||||||||||
| 58 | 3 | $self->_check_state('new'); | |||||||||||||||||||||||
| 59 | 3 | ▶ | my $perl = $self->{perl} or return; | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 60 | 3 | $self->{pid} = open2($self->{in}, $self->{out}, $^X); | |||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||
| 62 | 3 | my $old = select($self->{out}); | |||||||||||||||||||||||
| 63 | 3 | $| = 1; | |||||||||||||||||||||||
| 64 | 3 | select $old; | |||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||
| 66 | 3 | ▶ | my $inc = Data::Dumper::Dumper([grep defined && !ref, @INC]); | ||||||||||||||||||||||
|
Condition33%1/3
defined $_ && !ref($_)
MC/DC0%0/2
defined $_ && !ref($_)
defined $_
!ref($_)
Truth table33%1/3
A && not(B)
A= defined $_B= !ref($_)
| |||||||||||||||||||||||||
| 67 | 3 | ▶ | my $debug_as_str = ($debug ? -1 : 'undef'); | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||
| 69 | 3 | my $code = <<EOC; | |||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||
| 71 | use lib \@{$inc}; | ||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||
| 73 | use strict; | ||||||||||||||||||||||||
| 74 | use warnings; | ||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||
| 76 | \$Net::SSH::Any::Test::Isolated::debug = $debug_as_str; | ||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||
| 78 | use Net::SSH::Any::Test::Isolated::_Slave; | ||||||||||||||||||||||||
| 79 | Net::SSH::Any::Test::Isolated::_Slave->run; | ||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||
| 81 | __END__ | ||||||||||||||||||||||||