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