|  line  | 
 stmt  | 
 bran  | 
 cond  | 
 sub  | 
 pod  | 
 time  | 
 code  | 
| 
1
 | 
  
 
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 package Command::Template::Runner;  | 
| 
2
 | 
3
 | 
 
 | 
 
 | 
  
3
  
 | 
 
 | 
58
 | 
 use 5.024000;  | 
| 
 
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
12
 | 
    | 
| 
3
 | 
3
 | 
 
 | 
 
 | 
  
3
  
 | 
 
 | 
20
 | 
 use warnings;  | 
| 
 
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5
 | 
    | 
| 
 
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
98
 | 
    | 
| 
4
 | 
3
 | 
 
 | 
 
 | 
  
3
  
 | 
 
 | 
18
 | 
 use experimental qw< signatures >;  | 
| 
 
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5
 | 
    | 
| 
 
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
20
 | 
    | 
| 
5
 | 
3
 | 
 
 | 
 
 | 
  
3
  
 | 
 
 | 
336
 | 
 no warnings qw< experimental::signatures >;  | 
| 
 
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
7
 | 
    | 
| 
 
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
251
 | 
    | 
| 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 { our $VERSION = '0.001' }  | 
| 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
8
 | 
3
 | 
 
 | 
 
 | 
  
3
  
 | 
 
 | 
21
 | 
 use Storable 'dclone';  | 
| 
 
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6
 | 
    | 
| 
 
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
164
 | 
    | 
| 
9
 | 
3
 | 
 
 | 
 
 | 
  
3
  
 | 
 
 | 
1366
 | 
 use Command::Template::Runner::Record;  | 
| 
 
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
9
 | 
    | 
| 
 
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
365
 | 
    | 
| 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # attributes  | 
| 
12
 | 
6
 | 
 
 | 
 
 | 
  
6
  
 | 
  
1
  
 | 
20
 | 
 sub instance ($self) { $self->{instance} }  | 
| 
 
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
18
 | 
    | 
| 
 
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
10
 | 
    | 
| 
 
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
93
 | 
    | 
| 
13
 | 
  
0
  
 | 
 
 | 
 
 | 
  
0
  
 | 
  
1
  
 | 
0
 | 
 sub last_run ($self) { $self->{last_run} }  | 
| 
 
 | 
  
0
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
    | 
| 
 
 | 
  
0
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
    | 
| 
 
 | 
  
0
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
    | 
| 
14
 | 
6
 | 
 
 | 
 
 | 
  
6
  
 | 
  
1
  
 | 
8
 | 
 sub options ($self, @new) {  | 
| 
 
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
11
 | 
    | 
| 
 
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
8
 | 
    | 
| 
 
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
12
 | 
    | 
| 
15
 | 
6
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
82
 | 
    return dclone($self->{options}) unless @new;  | 
| 
16
 | 
  
0
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
    $self->{options} = $new[0];  | 
| 
17
 | 
  
0
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
    return $self;  | 
| 
18
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
19
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
20
 | 
3
 | 
 
 | 
 
 | 
  
3
  
 | 
 
 | 
3063
 | 
 use IPC::Run ();  | 
| 
 
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
126878
 | 
    | 
| 
 
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1415
 | 
    | 
| 
21
 | 
6
 | 
 
 | 
 
 | 
  
6
  
 | 
 
 | 
11
 | 
 sub __ipc_run ($command, %options) {  | 
| 
 
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
12
 | 
    | 
| 
 
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
33
 | 
    | 
| 
 
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
9
 | 
    | 
| 
22
 | 
6
 | 
 
 | 
  
100
  
 | 
 
 | 
 
 | 
66
 | 
    my $in = $options{stdin} // '';  | 
| 
23
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
23
 | 
    my $out = '';  | 
| 
24
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
36
 | 
    my $err = '';  | 
| 
25
 | 
6
 | 
 
 | 
  
 50
  
 | 
 
 | 
 
 | 
69
 | 
    my $timeout = $options{timeout} // 0;  | 
| 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
27
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
28
 | 
    my @args = ($command, \$in, \$out, \$err);  | 
| 
28
 | 
6
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
18
 | 
    push @args, IPC::Run::timeout($timeout) if $timeout;  | 
| 
29
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
30
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    eval {  | 
| 
31
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
32
 | 
       IPC::Run::run(@args);  | 
| 
32
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
67888
 | 
       $timeout = 0;  | 
| 
33
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
44
 | 
       1;  | 
| 
34
 | 
6
 | 
  
  0
  
 | 
 
 | 
 
 | 
 
 | 
15
 | 
    } or do { die $@ if $@ !~ m{^IPC::Run:\s*timeout} };  | 
| 
 
 | 
0
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
0
 | 
    | 
| 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
36
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    return {  | 
| 
37
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
488
 | 
       command => $command,  | 
| 
38
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
       ec      => $?,  | 
| 
39
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
       options => \%options,  | 
| 
40
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
       stderr  => $err,  | 
| 
41
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
       stdout  => $out,  | 
| 
42
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
       timeout => $timeout,  | 
| 
43
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    };  | 
| 
44
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
45
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
46
 | 
1
 | 
 
 | 
 
 | 
  
1
  
 | 
  
1
  
 | 
3
 | 
 sub new ($p, $i) { return bless { instance => $i, options => {} }, $p }  | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2
 | 
    | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
3
 | 
    | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1
 | 
    | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6
 | 
    | 
| 
47
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
48
 | 
6
 | 
 
 | 
 
 | 
  
6
  
 | 
  
1
  
 | 
2294
 | 
 sub run ($self, %bindopts) {  | 
| 
 
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
16
 | 
    | 
| 
 
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
42
 | 
    | 
| 
 
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
13
 | 
    | 
| 
49
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
14
 | 
    my (%bindings, %options); # split %bindopts into these hashes  | 
| 
50
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
44
 | 
    while (my ($key, $value) = each %bindopts) {  | 
| 
51
 | 
9
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
36
 | 
       if (substr($key, 0, 1) eq '-') {  | 
| 
52
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
18
 | 
          $options{substr $key, 1} = $value;  | 
| 
53
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
       }  | 
| 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
       else {  | 
| 
55
 | 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
34
 | 
          $bindings{$key} = $value;  | 
| 
56
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
       }  | 
| 
57
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    }  | 
| 
58
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
63
 | 
    my $cmd = $self->instance->generate(%bindings);  | 
| 
59
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
13
 | 
    %options = (%{$self->options}, %options);  | 
| 
 
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
24
 | 
    | 
| 
60
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    my $run = $self->{last_run}  | 
| 
61
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
29
 | 
       = Command::Template::Runner::Record->new(__ipc_run($cmd, %options));  | 
| 
62
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
218
 | 
    return $run;  | 
| 
63
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
64
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
65
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 1;  |