blib/lib/App/TestOnTap/Preprocess.pm

filter: Statementstmt 100% 61 / 61 Branchbran 75.0% 15 / 20 Conditioncond 75.0% 6 / 8 MC/DCmcdc 60.0% 3 / 5 Subroutinesub 100% 13 / 13 Podpod 0.0% 0 / 3 totaltotal 89.0% 98 / 110 SCAR 26.5
CC
14
Cov
92%
__parseEnvLines
5.0
__execPreprocess
5.0
__parseArgvLines
3.0
CRAP 14.1
« blib/lib/App/TestOnTap/ExecMap.pm ↑ Summary blib/lib/App/TestOnTap/OrderStrategy.pm »
1 package App::TestOnTap::Preprocess;
2  
3 19 ▶use POSIX;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 19 ▶use App::TestOnTap::Util qw(runprocess);
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 19 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 19 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 # CTOR
10 #
11 sub new
12 {
13 27 ▶ my $class = shift;
Subroutine new: called CC=3 SCAR=11.0
Pod undocumented
14 27 my $cmd = shift;
15 27 my $args = shift;
16 27 my $env = shift;
17 27 my $argv = shift;
18  
19 27 my $self = bless( { env => $env, argv => $argv }, $class);
20 27 ▶ $self->__execPreprocess($cmd, $args) if ($cmd && @$cmd);
Branch: 1 branch
BranchTrueFalseTotal
if $cmd and @$cmd 1 26 27
Condition66%2/3
$cmd and @$cmd
!ll&&!rl&&r
0261
MC/DC50%1/2
$cmd and @$cmd
$cmd @$cmd
Truth table66%2/3
A and B
A= $cmdB= @$cmd
ABresult
0X0
100
111
21
22 27 return $self;
23 }
24  
25 sub getEnv
26 {
27 26 ▶ my $self = shift;
Subroutine getEnv: called CC=1 SCAR=0.0
Pod undocumented
28
29 26 return $self->{env};
30 }
31  
32 sub getArgv
33 {
34 50 ▶ my $self = shift;
Subroutine getArgv: called CC=1 SCAR=0.0
Pod undocumented
35  
36 50 return $self->{argv};
37 }
38  
39 sub __execPreprocess
40 {
41 1 ▶ my $self = shift;
Subroutine __execPreprocess: called CC=5 SCAR=16.1
42 1 my $cmd = shift;
43 1 my $args = shift;
44  
45 1 my @preproc;
46 my $xit = runprocess
47 (
48 sub
49 {
50 39 ▶ my $l = shift;
Subroutine __ANON__: called CC=2 SCAR=7.0
51 39 chomp($l);
52 39 $l =~ s/^\s+|\s+$//g;
53 39 ▶ push(@preproc, $l) if $l;
Branch: 1 branch
BranchTrueFalseTotal
if $l 39 0 39
54 },
55 $args->getSuiteRoot(),
56 (
57 @$cmd,
58 1 @{$self->getArgv()}
59 )
60 );
61
62 1 ▶ die("ERROR: exit code '$xit' when running preprocess command\n") if $xit;
Branch: 1 branch
BranchTrueFalseTotal
if $xit 0 1 1
63  
64 1 $args->getWorkDirManager()->recordPreprocess([ @preproc ]);
65  
66 my %types =
67 (
68 1 ▶ ENV => sub { $self->__parseEnvLines(@_) },
Subroutine __ANON__: called CC=1 SCAR=0.0
69 1 ▶ ARGV => sub { $self->__parseArgvLines(@_) }
Subroutine __ANON__: called CC=1 SCAR=0.0
70 1 );
71  
72 1 ▶ while (my $line = shift(@preproc))
Branch: 1 branch
BranchTrueFalseTotal
if (my $line = shift @preproc) 4 1 5
73 {
74 4 ▶ if ($line =~ /^\s*#\s*BEGIN\s+([^\s]+)\s*$/ && exists($types{$1}))
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^\s*#\s*BEGIN\s+([^\s]+)\s*$/ and exists $types{$1}) { } 2 2 4
Condition66%2/3
$line =~ /^\s*#\s*BEGIN\s+([^\s]+)\s*$/ and exists $types{$1}
!ll&&!rl&&r
202
MC/DC50%1/2
$line =~ /^\s*#\s*BEGIN\s+([^\s]+)\s*$/ and exists $types{$1}
$line =~ /^\s*#\s*BEGIN\s+([^\s]+)\s*$/ exists $types{$1}
Truth table66%2/3
A and B
A= $line =~ /^\s*#\s*BEGIN\s+([^\s]+)\s*$/B= exists $types{$1}
ABresult
0X0
100
111
75 {
76 2 $types{$1}->($1, \@preproc);
77 }
78 else
79 {
80 2 warn("WARNING: Unexpected line during preprocessing: '$line'\n");
81 }
82 }
83 }
84  
85 sub __parseEnvLines
86 {
87 1 ▶ my $self = shift;
Subroutine __parseEnvLines: called CC=5 SCAR=16.2
88 1 my $type = shift;
89 1 my $preproc = shift;
90  
91 1 my %env;
92 1 ▶ while (my $line = shift(@$preproc))
Branch: 1 branch
BranchTrueFalseTotal
if (my $line = shift @$preproc) 32 0 32
93 {
94 32 ▶ last if $line =~ /^\s*#\s*END\s+\Q$type\E\s*$/;
Branch: 1 branch
BranchTrueFalseTotal
if $line =~ /^\s*#\s*END\s+\Q$type\E\s*$/ 1 31 32
95 31 ▶ die("Invalid $type line during preprocessing: '$line'\n") unless ($line =~ /^([^=]+)=(.*)/);
Branch: 1 branch
BranchTrueFalseTotal
unless $line =~ /^([^=]+)=(.*)/ 0 31 31
96 31 ▶ $env{$1} = $2 || '';
Condition100%2/2
$2 || ''
l!l
292
MC/DC100%1/1
$2 || ''
$2
Truth table100%2/2
A
A= $2
Aresult
11
00
97 }
98
99 1 $self->{env} = \%env;
100 }
101  
102 sub __parseArgvLines
103 {
104 1 ▶ my $self = shift;
Subroutine __parseArgvLines: called CC=3 SCAR=11.0
105 1 my $type = shift;
106 1 my $preproc = shift;
107  
108 1 my @argv;
109 1 ▶ while (my $line = shift(@$preproc))
Branch: 1 branch
BranchTrueFalseTotal
if (my $line = shift @$preproc) 3 0 3
110 {
111 3 ▶ last if $line =~ /^\s*#\s*END\s+\Q$type\E\s*$/;
Branch: 1 branch
BranchTrueFalseTotal
if $line =~ /^\s*#\s*END\s+\Q$type\E\s*$/ 1 2 3
112 2 push(@argv, $line);
113 }
114
115 1 $self->{argv} = \@argv;
116 }
117  
118 19 1;
« blib/lib/App/TestOnTap/ExecMap.pm ↑ Summary blib/lib/App/TestOnTap/OrderStrategy.pm »