Cinnamon/Runner.pm

filter: Statementstmt 100% 44 / 44 Branchbran 100% 4 / 4 Conditioncond 50.0% 2 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 2 totaltotal 90.7% 59 / 65 CC 7 SCAR 11.5
CC
7
Cov
96%
start
6.0
execute
2.0
BEGIN
1.0
CRAP 3.1
« Cinnamon/Context.pm ↑ Summary Cinnamon/Logger.pm »
1 package Cinnamon::Runner;
2 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 3 ▶use Cinnamon qw(CTX);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use Cinnamon::Logger;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 3 ▶use Coro;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use Coro::Select;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 11 ▶sub start {
Subroutine start: called CC=6 SCAR=18.0
Pod undocumented
12 11 my ($class, $hosts, $task) = @_;
13 11 my $all_results = {};
14 11 $hosts = [ @$hosts ];
15  
16 11 my $task_name = $task->name;
17 11 ▶ my $concurrency_setting = CTX->get_param('concurrency') || {};
Condition50%1/2
CTX()->get_param('concurrency') || {}
l!l
011
MC/DC0%0/1
CTX()->get_param('concurrency') || {}
CTX()->get_param('concurrency')
Truth table50%1/2
A
A= CTX()->get_param('concurrency')
Aresult
11
00
18 11 ▶ my $concurrency = $concurrency_setting->{$task_name} || scalar @$hosts;
Condition50%1/2
$concurrency_setting->{$task_name} || scalar @$hosts
l!l
011
MC/DC0%0/1
$concurrency_setting->{$task_name} || scalar @$hosts
$concurrency_setting->{$task_name}
Truth table50%1/2
A
A= $concurrency_setting->{$task_name}
Aresult
11
00
19  
20 11 ▶ while (my @target_hosts = splice @$hosts, 0, $concurrency) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@target_hosts) = splice(@$hosts, 0, $concurrency)) 11 11 22
21 11 my @coros;
22  
23 11 for my $host (@target_hosts) {
24 11 ▶ my $coro = async {
Subroutine __ANON__: called CC=1 SCAR=0.0
25 11 my $result = $class->execute($host, $task);
26 11 $all_results->{$host} = $result;
27 11 };
28  
29 11 push @coros, $coro;
30 }
31  
32 11 $_->join for @coros;
33 }
34  
35 11 return $all_results;
36 }
37  
38 11 ▶sub execute {
Subroutine execute: called CC=2 SCAR=6.9
Pod undocumented
39 11 my ($class, $host, $task) = @_;
40  
41 11 my $result = { host => $host, error => 0 };
42  
43 11 local $@;
44 11 eval { $task->execute($host) };
45 11 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 3 8 11
46 3 chomp $@;
47 3 log error => sprintf '[%s] %s', $host, $@;
48 3 $result->{error} = 1;
49 }
50  
51 11 return $result;
52 }
53  
54 3 1;
« Cinnamon/Context.pm ↑ Summary Cinnamon/Logger.pm »