| 1 | package Proc::Class; | ||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 1 | ▶ | use Any::Moose; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 1 | our $VERSION = '0.05'; | |||||||||||
| 6 | 1 | ▶ | use 5.008001; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 1 | our @EXPORT = qw/test_script/; | |||||||||||
| 8 | 1 | ▶ | use Proc::Class::Status; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | 1 | ▶ | use IPC::Open3 (); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | |||||||||||||
| 11 | 1 | has stdin => ( | |||||||||||
| 12 | is => 'rw', | ||||||||||||
| 13 | ); | ||||||||||||
| 14 | |||||||||||||
| 15 | 1 | has stdout => ( | |||||||||||
| 16 | is => 'rw', | ||||||||||||
| 17 | ); | ||||||||||||
| 18 | |||||||||||||
| 19 | 1 | has stderr => ( | |||||||||||
| 20 | is => 'rw', | ||||||||||||
| 21 | ); | ||||||||||||
| 22 | |||||||||||||
| 23 | 1 | has pid => ( | |||||||||||
| 24 | is => 'rw', | ||||||||||||
| 25 | isa => 'Int', | ||||||||||||
| 26 | ); | ||||||||||||
| 27 | |||||||||||||
| 28 | 1 | has cmd => ( | |||||||||||
| 29 | is => 'ro', | ||||||||||||
| 30 | isa => 'Str', | ||||||||||||
| 31 | ); | ||||||||||||
| 32 | |||||||||||||
| 33 | has env => ( | ||||||||||||
| 34 | is => 'ro', | ||||||||||||
| 35 | isa => 'HashRef', | ||||||||||||
| 36 | 0 | ▶ | default => sub { \%ENV }, | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 37 | 1 | ); | |||||||||||
| 38 | |||||||||||||
| 39 | has argv => ( | ||||||||||||
| 40 | is => 'ro', | ||||||||||||
| 41 | isa => 'ArrayRef', | ||||||||||||
| 42 | 0 | ▶ | default => sub { +[] }, | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 43 | 1 | ); | |||||||||||
| 44 | |||||||||||||
| 45 | 0 | ▶ | sub BUILD { | ||||||||||
|
Subroutine
BUILD: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 46 | 0 | my $self = shift; | |||||||||||
| 47 | |||||||||||||
| 48 | 0 | local %ENV = (%ENV, %{ $self->env }); | |||||||||||
| 49 | |||||||||||||
| 50 | 0 | my ($in, $out, $err); | |||||||||||
| 51 | 0 | my $pid = IPC::Open3::open3($in, $out, $err, $self->cmd, @{ $self->argv }); | |||||||||||
| 52 | 0 | $self->pid($pid); | |||||||||||
| 53 | 0 | $self->stdin($in); | |||||||||||
| 54 | 0 | $self->stdout($out); | |||||||||||
| 55 | 0 | $self->stderr($err); | |||||||||||
| 56 | } | ||||||||||||
| 57 | |||||||||||||
| 58 | 0 | ▶ | sub print_stdin { | ||||||||||
|
Subroutine
print_stdin: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 59 | 0 | my ($self, $txt) = @_; | |||||||||||
| 60 | 0 | my $fh = $self->{stdin}; | |||||||||||
| 61 | 0 | print $fh $txt; | |||||||||||
| 62 | } | ||||||||||||
| 63 | |||||||||||||
| 64 | 0 | ▶ | sub close_stdin { | ||||||||||
|
Subroutine
close_stdin: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 65 | 0 | my $self = shift; | |||||||||||
| 66 | 0 | close $self->{stdin}; | |||||||||||
| 67 | } | ||||||||||||
| 68 | |||||||||||||
| 69 | 0 | ▶ | sub slurp_stdout { | ||||||||||
|
Subroutine
slurp_stdout: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 70 | 0 | my ($self, $expected) = @_; | |||||||||||
| 71 | 0 | my $fh = $self->stdout; | |||||||||||
| 72 | 0 | my $got = join '', <$fh>; | |||||||||||
| 73 | 0 | return $got; | |||||||||||
| 74 | } | ||||||||||||
| 75 | |||||||||||||
| 76 | 0 | ▶ | sub slurp_stderr { | ||||||||||
|
Subroutine
slurp_stderr: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||
| 77 | 0 | my ($self, $expected) = @_; | |||||||||||
| 78 | 0 | my $fh = $self->stderr; | |||||||||||
| 79 | 0 | ▶ | if ($fh) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 80 | 0 | my $got = join '', <$fh>; | |||||||||||
| 81 | 0 | return $got; | |||||||||||
| 82 | } else { | ||||||||||||
| 83 | 0 | return ''; | |||||||||||
| 84 | } | ||||||||||||
| 85 | } | ||||||||||||
| 86 | |||||||||||||
| 87 | 0 | ▶ | sub waitpid { | ||||||||||
|
Subroutine
waitpid: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 88 | 0 | my $self = shift; | |||||||||||
| 89 | 0 | waitpid($self->{pid}, 0); | |||||||||||
| 90 | 0 | return Proc::Class::Status->new(status => $?); | |||||||||||
| 91 | } | ||||||||||||
| 92 | |||||||||||||
| 93 | 0 | ▶ | sub kill { | ||||||||||
|
Subroutine
kill: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||
| 94 | 0 | my ($self, $signal) = @_; | |||||||||||
| 95 | 0 | ▶ | $signal ||= 'TERM'; | ||||||||||
|
Condition0%0/2
$signal ||= "TERM"
MC/DC0%0/1
$signal ||= "TERM"
$signal
Truth table0%0/2
A
A= $signal
| |||||||||||||
| 96 | 0 | kill $signal, $self->pid; | |||||||||||
| 97 | } | ||||||||||||
| 98 | |||||||||||||
| 99 | 1 | ▶ | no Any::Moose; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 100 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||||
| 101 | __END__ | ||||||||||||