| 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
Condition66%2/3
$cmd and @$cmd
MC/DC50%1/2
$cmd and @$cmd
$cmd
@$cmd
Truth table66%2/3
A and B
A= $cmdB= @$cmd
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 73 | { | ||||||||||||||||||||||||||||
| 74 | 4 | ▶ | if ($line =~ /^\s*#\s*BEGIN\s+([^\s]+)\s*$/ && exists($types{$1})) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$line =~ /^\s*#\s*BEGIN\s+([^\s]+)\s*$/ and exists $types{$1}
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}
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 93 | { | ||||||||||||||||||||||||||||
| 94 | 32 | ▶ | last if $line =~ /^\s*#\s*END\s+\Q$type\E\s*$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 95 | 31 | ▶ | die("Invalid $type line during preprocessing: '$line'\n") unless ($line =~ /^([^=]+)=(.*)/); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 96 | 31 | ▶ | $env{$1} = $2 || ''; | ||||||||||||||||||||||||||
|
Condition100%2/2
$2 || ''
MC/DC100%1/1
$2 || ''
$2
Truth table100%2/2
A
A= $2
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 110 | { | ||||||||||||||||||||||||||||
| 111 | 3 | ▶ | last if $line =~ /^\s*#\s*END\s+\Q$type\E\s*$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 112 | 2 | push(@argv, $line); | |||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | 1 | $self->{argv} = \@argv; | |||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 19 | 1; | |||||||||||||||||||||||||||