line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::TestOnTap::Preprocess; |
2
|
|
|
|
|
|
|
|
3
|
19
|
|
|
19
|
|
153
|
use App::TestOnTap::Util qw(runprocess); |
|
19
|
|
|
|
|
44
|
|
|
19
|
|
|
|
|
1060
|
|
4
|
|
|
|
|
|
|
|
5
|
19
|
|
|
19
|
|
129
|
use POSIX; |
|
19
|
|
|
|
|
45
|
|
|
19
|
|
|
|
|
139
|
|
6
|
|
|
|
|
|
|
|
7
|
19
|
|
|
19
|
|
30563
|
use strict; |
|
19
|
|
|
|
|
53
|
|
|
19
|
|
|
|
|
453
|
|
8
|
19
|
|
|
19
|
|
114
|
use warnings; |
|
19
|
|
|
|
|
60
|
|
|
19
|
|
|
|
|
13599
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# CTOR |
11
|
|
|
|
|
|
|
# |
12
|
|
|
|
|
|
|
sub new |
13
|
|
|
|
|
|
|
{ |
14
|
27
|
|
|
27
|
0
|
98
|
my $class = shift; |
15
|
27
|
|
|
|
|
77
|
my $cmd = shift; |
16
|
27
|
|
|
|
|
62
|
my $args = shift; |
17
|
27
|
|
|
|
|
69
|
my $env = shift; |
18
|
27
|
|
|
|
|
55
|
my $argv = shift; |
19
|
|
|
|
|
|
|
|
20
|
27
|
|
|
|
|
181
|
my $self = bless( { env => $env, argv => $argv }, $class); |
21
|
27
|
100
|
66
|
|
|
270
|
$self->__execPreprocess($cmd, $args) if ($cmd && @$cmd); |
22
|
|
|
|
|
|
|
|
23
|
27
|
|
|
|
|
682
|
return $self; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub getEnv |
27
|
|
|
|
|
|
|
{ |
28
|
26
|
|
|
26
|
0
|
71
|
my $self = shift; |
29
|
|
|
|
|
|
|
|
30
|
26
|
|
|
|
|
2328
|
return $self->{env}; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub getArgv |
34
|
|
|
|
|
|
|
{ |
35
|
50
|
|
|
50
|
0
|
141
|
my $self = shift; |
36
|
|
|
|
|
|
|
|
37
|
50
|
|
|
|
|
373
|
return $self->{argv}; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub __execPreprocess |
41
|
|
|
|
|
|
|
{ |
42
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
43
|
1
|
|
|
|
|
2
|
my $cmd = shift; |
44
|
1
|
|
|
|
|
2
|
my $args = shift; |
45
|
|
|
|
|
|
|
|
46
|
1
|
|
|
|
|
3
|
my @preproc; |
47
|
|
|
|
|
|
|
my $xit = runprocess |
48
|
|
|
|
|
|
|
( |
49
|
43
|
|
|
43
|
|
617
|
sub { push(@preproc, $_[0])}, |
50
|
|
|
|
|
|
|
$args->getSuiteRoot(), |
51
|
|
|
|
|
|
|
( |
52
|
|
|
|
|
|
|
@$cmd, |
53
|
1
|
|
|
|
|
9
|
@{$self->getArgv()} |
|
1
|
|
|
|
|
5
|
|
54
|
|
|
|
|
|
|
) |
55
|
|
|
|
|
|
|
); |
56
|
1
|
50
|
|
|
|
81
|
die("ERROR: exit code '$xit' when running preprocess command\n") if $xit; |
57
|
|
|
|
|
|
|
|
58
|
1
|
|
|
|
|
20
|
$args->getWorkDirManager()->recordPreprocess([ @preproc ]); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
my %types = |
61
|
|
|
|
|
|
|
( |
62
|
|
|
|
|
|
|
ENV => sub |
63
|
|
|
|
|
|
|
{ |
64
|
1
|
|
|
1
|
|
17
|
$self->__parseEnvLines(@_) |
65
|
|
|
|
|
|
|
}, |
66
|
|
|
|
|
|
|
ARGV => sub |
67
|
|
|
|
|
|
|
{ |
68
|
1
|
|
|
1
|
|
13
|
$self->__parseArgvLines(@_) |
69
|
|
|
|
|
|
|
} |
70
|
1
|
|
|
|
|
59
|
); |
71
|
|
|
|
|
|
|
|
72
|
1
|
|
|
|
|
17
|
chomp(@preproc); |
73
|
1
|
|
|
|
|
11
|
while (my $line = shift(@preproc)) |
74
|
|
|
|
|
|
|
{ |
75
|
4
|
100
|
66
|
|
|
95
|
if ($line =~ /^\s*#\s*BEGIN\s+([^\s]+)\s*$/ && exists($types{$1})) |
76
|
|
|
|
|
|
|
{ |
77
|
2
|
|
|
|
|
21
|
$types{$1}->($1, \@preproc); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
else |
80
|
|
|
|
|
|
|
{ |
81
|
2
|
|
|
|
|
61
|
warn("WARNING: Unexpected line during preprocessing: '$line'\n"); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub __parseEnvLines |
87
|
|
|
|
|
|
|
{ |
88
|
1
|
|
|
1
|
|
20
|
my $self = shift; |
89
|
1
|
|
|
|
|
11
|
my $type = shift; |
90
|
1
|
|
|
|
|
5
|
my $preproc = shift; |
91
|
|
|
|
|
|
|
|
92
|
1
|
|
|
|
|
3
|
my %env; |
93
|
1
|
|
|
|
|
35
|
while (my $line = shift(@$preproc)) |
94
|
|
|
|
|
|
|
{ |
95
|
36
|
100
|
|
|
|
216
|
last if $line =~ /^\s*#\s*END\s+\Q$type\E\s*$/; |
96
|
35
|
50
|
|
|
|
152
|
die("Invalid $type line during preprocessing: '$line'\n") unless ($line =~ /^([^=]+)=(.*)/); |
97
|
35
|
|
100
|
|
|
264
|
$env{$1} = $2 || ''; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
1
|
|
|
|
|
11
|
$self->{env} = \%env; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub __parseArgvLines |
104
|
|
|
|
|
|
|
{ |
105
|
1
|
|
|
1
|
|
7
|
my $self = shift; |
106
|
1
|
|
|
|
|
5
|
my $type = shift; |
107
|
1
|
|
|
|
|
6
|
my $preproc = shift; |
108
|
|
|
|
|
|
|
|
109
|
1
|
|
|
|
|
4
|
my @argv; |
110
|
1
|
|
|
|
|
22
|
while (my $line = shift(@$preproc)) |
111
|
|
|
|
|
|
|
{ |
112
|
3
|
100
|
|
|
|
48
|
last if $line =~ /^\s*#\s*END\s+\Q$type\E\s*$/; |
113
|
2
|
|
|
|
|
16
|
push(@argv, $line); |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
1
|
|
|
|
|
18
|
$self->{argv} = \@argv; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
1; |