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