| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::TestOnTap::ExecMap; |
|
2
|
|
|
|
|
|
|
|
|
3
|
19
|
|
|
19
|
|
132
|
use strict; |
|
|
19
|
|
|
|
|
39
|
|
|
|
19
|
|
|
|
|
601
|
|
|
4
|
19
|
|
|
19
|
|
116
|
use warnings; |
|
|
19
|
|
|
|
|
35
|
|
|
|
19
|
|
|
|
|
669
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
19
|
|
|
19
|
|
115
|
use App::TestOnTap::Util qw(trim $IS_WINDOWS ensureArray); |
|
|
19
|
|
|
|
|
35
|
|
|
|
19
|
|
|
|
|
1911
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
19
|
|
|
19
|
|
9370
|
use Grep::Query; |
|
|
19
|
|
|
|
|
1016435
|
|
|
|
19
|
|
|
|
|
12231
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# CTOR |
|
11
|
|
|
|
|
|
|
# |
|
12
|
|
|
|
|
|
|
sub new |
|
13
|
|
|
|
|
|
|
{ |
|
14
|
27
|
|
|
27
|
0
|
78
|
my $class = shift; |
|
15
|
27
|
|
|
|
|
58
|
my $cfg = shift; |
|
16
|
|
|
|
|
|
|
|
|
17
|
27
|
|
|
|
|
123
|
my $self = bless( {}, $class); |
|
18
|
27
|
|
|
|
|
150
|
$self->__parseExecMap($cfg); |
|
19
|
|
|
|
|
|
|
|
|
20
|
27
|
|
|
|
|
169
|
return $self; |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub __parseExecMap |
|
24
|
|
|
|
|
|
|
{ |
|
25
|
27
|
|
|
27
|
|
64
|
my $self = shift; |
|
26
|
27
|
|
|
|
|
55
|
my $cfg = shift; |
|
27
|
|
|
|
|
|
|
|
|
28
|
27
|
|
|
|
|
64
|
my @matcherCmdlinePairs; |
|
29
|
|
|
|
|
|
|
|
|
30
|
27
|
|
|
|
|
84
|
my $emOrder = $cfg->{''}->{execmap}; |
|
31
|
27
|
100
|
|
|
|
101
|
if (!$emOrder) |
|
32
|
|
|
|
|
|
|
{ |
|
33
|
25
|
|
|
|
|
984
|
warn("WARNING: No execmap found, using internal default!\n"); |
|
34
|
25
|
|
|
|
|
212
|
$cfg = __defaultCfg(); |
|
35
|
25
|
|
|
|
|
93
|
$emOrder = $cfg->{''}->{execmap}; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
27
|
|
|
|
|
135
|
$emOrder = ensureArray($emOrder); |
|
38
|
|
|
|
|
|
|
|
|
39
|
27
|
|
|
|
|
100
|
foreach my $em (@$emOrder) |
|
40
|
|
|
|
|
|
|
{ |
|
41
|
202
|
|
|
|
|
669
|
my $emSec = $cfg->{"EXECMAP $em"}; |
|
42
|
202
|
50
|
|
|
|
539
|
die("Missing execmap section for '$em'\n") unless $emSec; |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# trip any unknown keys |
|
45
|
|
|
|
|
|
|
# |
|
46
|
202
|
|
|
|
|
1900
|
warn("WARNING: Unknown key '$_' in execmap section '$em'\n") foreach (grep(!/^(match|cmd)$/, keys(%$emSec))); |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# extract the ones we want |
|
49
|
|
|
|
|
|
|
# |
|
50
|
202
|
|
|
|
|
577
|
my $match = $emSec->{match}; |
|
51
|
202
|
|
100
|
|
|
758
|
my $cmd = $emSec->{cmd} || ''; |
|
52
|
202
|
50
|
|
|
|
481
|
die("The execmap section '$em' must have at least the 'match' key\n") unless $match; |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# compile the query |
|
55
|
|
|
|
|
|
|
# |
|
56
|
202
|
|
|
|
|
786
|
my $matcher = Grep::Query->new($match); |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# we want to store the cmd as an array |
|
59
|
|
|
|
|
|
|
# Config::Std allows it to be in multiple forms: |
|
60
|
|
|
|
|
|
|
# a single line (we split it on space) |
|
61
|
|
|
|
|
|
|
# a ready-made array (take as is) |
|
62
|
|
|
|
|
|
|
# a string with embedded \n (split on that) |
|
63
|
|
|
|
|
|
|
# |
|
64
|
202
|
|
|
|
|
1391224
|
my $cmdline = ensureArray($cmd); |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# now store the matcher and cmdline in an array so we can evaluate them |
|
67
|
|
|
|
|
|
|
# in a defined order when we need to |
|
68
|
|
|
|
|
|
|
# |
|
69
|
202
|
|
|
|
|
812
|
push(@matcherCmdlinePairs, [ $matcher, $cmdline ]); |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# not much meaning in continuing if there are no mappings at all...! |
|
73
|
|
|
|
|
|
|
# |
|
74
|
27
|
50
|
|
|
|
154
|
die("No entries in the execmap\n") unless @matcherCmdlinePairs; |
|
75
|
|
|
|
|
|
|
|
|
76
|
27
|
|
|
|
|
437
|
$self->{mcpairs} = \@matcherCmdlinePairs; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub __defaultCfg |
|
80
|
|
|
|
|
|
|
{ |
|
81
|
|
|
|
|
|
|
# TODO: add more useful standard mappings here |
|
82
|
|
|
|
|
|
|
# |
|
83
|
25
|
|
|
25
|
|
975
|
my %cfg = |
|
84
|
|
|
|
|
|
|
( |
|
85
|
|
|
|
|
|
|
'' => |
|
86
|
|
|
|
|
|
|
{ |
|
87
|
|
|
|
|
|
|
execmap => [qw(perl python java groovy shell autoit3 batch binary)] |
|
88
|
|
|
|
|
|
|
}, |
|
89
|
|
|
|
|
|
|
'EXECMAP perl' => |
|
90
|
|
|
|
|
|
|
{ |
|
91
|
|
|
|
|
|
|
# well, a no-brainer...:-) |
|
92
|
|
|
|
|
|
|
# |
|
93
|
|
|
|
|
|
|
'match' => 'regexp[\.(t|pl)$]', |
|
94
|
|
|
|
|
|
|
'cmd' => 'perl', |
|
95
|
|
|
|
|
|
|
}, |
|
96
|
|
|
|
|
|
|
'EXECMAP python' => |
|
97
|
|
|
|
|
|
|
{ |
|
98
|
|
|
|
|
|
|
# if python is preferred... |
|
99
|
|
|
|
|
|
|
# |
|
100
|
|
|
|
|
|
|
'match' => 'regexp[\.py$]', |
|
101
|
|
|
|
|
|
|
'cmd' => 'python', |
|
102
|
|
|
|
|
|
|
}, |
|
103
|
|
|
|
|
|
|
'EXECMAP java' => |
|
104
|
|
|
|
|
|
|
{ |
|
105
|
|
|
|
|
|
|
# quite possible and important for java shops |
|
106
|
|
|
|
|
|
|
# (couple with some nice junit and other helpers) |
|
107
|
|
|
|
|
|
|
# |
|
108
|
|
|
|
|
|
|
'match' => 'regexp[\.jar$]', |
|
109
|
|
|
|
|
|
|
'cmd' => [qw(java -jar)], |
|
110
|
|
|
|
|
|
|
}, |
|
111
|
|
|
|
|
|
|
'EXECMAP groovy' => |
|
112
|
|
|
|
|
|
|
{ |
|
113
|
|
|
|
|
|
|
# common variants for groovy scripts, I understand... |
|
114
|
|
|
|
|
|
|
# |
|
115
|
|
|
|
|
|
|
'match' => 'regexp[\.(groovy|gsh|gvy|gy)$]', |
|
116
|
|
|
|
|
|
|
'cmd' => 'groovy', |
|
117
|
|
|
|
|
|
|
}, |
|
118
|
|
|
|
|
|
|
'EXECMAP shell' => |
|
119
|
|
|
|
|
|
|
{ |
|
120
|
|
|
|
|
|
|
# shell scripting is powerful, so why not |
|
121
|
|
|
|
|
|
|
# |
|
122
|
|
|
|
|
|
|
'match' => 'regexp[\.sh$]', |
|
123
|
|
|
|
|
|
|
'cmd' => 'sh', |
|
124
|
|
|
|
|
|
|
}, |
|
125
|
|
|
|
|
|
|
'EXECMAP autoit3' => |
|
126
|
|
|
|
|
|
|
{ |
|
127
|
|
|
|
|
|
|
# For using AutoIt scripts (https://www.autoitscript.com/site/autoit/) |
|
128
|
|
|
|
|
|
|
# (Windows only) |
|
129
|
|
|
|
|
|
|
# |
|
130
|
|
|
|
|
|
|
'match' => 'regexp[\.au3$]', |
|
131
|
|
|
|
|
|
|
'cmd' => 'autoit3', |
|
132
|
|
|
|
|
|
|
}, |
|
133
|
|
|
|
|
|
|
'EXECMAP batch' => |
|
134
|
|
|
|
|
|
|
{ |
|
135
|
|
|
|
|
|
|
# possible, but perhaps not likely |
|
136
|
|
|
|
|
|
|
# (Windows only) |
|
137
|
|
|
|
|
|
|
# |
|
138
|
|
|
|
|
|
|
'match' => 'regexp[\.(bat|cmd)$]', |
|
139
|
|
|
|
|
|
|
'cmd' => [qw(cmd.exe /c)], |
|
140
|
|
|
|
|
|
|
}, |
|
141
|
|
|
|
|
|
|
'EXECMAP binary' => |
|
142
|
|
|
|
|
|
|
{ |
|
143
|
|
|
|
|
|
|
# for directly executable binaries, no actual 'cmd' is needed |
|
144
|
|
|
|
|
|
|
# On Windows: rename 'xyz.exe' => 'xyz.tbin' |
|
145
|
|
|
|
|
|
|
# On Unix: rename 'xyz' => 'xyz.tbin' |
|
146
|
|
|
|
|
|
|
# |
|
147
|
|
|
|
|
|
|
'match' => 'regexp[\.tbin$]', |
|
148
|
|
|
|
|
|
|
}, |
|
149
|
|
|
|
|
|
|
); |
|
150
|
|
|
|
|
|
|
|
|
151
|
25
|
|
|
|
|
157
|
return \%cfg; |
|
152
|
|
|
|
|
|
|
} |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
# just check if the given test has a mapping |
|
155
|
|
|
|
|
|
|
# |
|
156
|
|
|
|
|
|
|
sub hasMapping |
|
157
|
|
|
|
|
|
|
{ |
|
158
|
56
|
|
|
56
|
0
|
139
|
my $self = shift; |
|
159
|
56
|
|
|
|
|
99
|
my $testName = shift; |
|
160
|
|
|
|
|
|
|
|
|
161
|
56
|
|
|
|
|
111
|
foreach my $matcherCmdlinePair (@{$self->{mcpairs}}) |
|
|
56
|
|
|
|
|
200
|
|
|
162
|
|
|
|
|
|
|
{ |
|
163
|
70
|
100
|
|
|
|
1590
|
return 1 if $matcherCmdlinePair->[0]->qgrep($testName); |
|
164
|
|
|
|
|
|
|
} |
|
165
|
|
|
|
|
|
|
|
|
166
|
2
|
50
|
|
|
|
172
|
if (defined($self->{delegate})) |
|
167
|
|
|
|
|
|
|
{ |
|
168
|
0
|
0
|
|
|
|
0
|
return 1 if $self->{delegate}->hasMapping($testName); |
|
169
|
|
|
|
|
|
|
} |
|
170
|
|
|
|
|
|
|
|
|
171
|
2
|
|
|
|
|
39
|
return 0; |
|
172
|
|
|
|
|
|
|
} |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
# retrieve the cmdline map for the test |
|
175
|
|
|
|
|
|
|
# |
|
176
|
|
|
|
|
|
|
sub getMapping |
|
177
|
|
|
|
|
|
|
{ |
|
178
|
48
|
|
|
48
|
0
|
157
|
my $self = shift; |
|
179
|
48
|
|
|
|
|
153
|
my $testName = shift; |
|
180
|
|
|
|
|
|
|
|
|
181
|
48
|
|
|
|
|
138
|
foreach my $matcherCmdlinePair (@{$self->{mcpairs}}) |
|
|
48
|
|
|
|
|
407
|
|
|
182
|
|
|
|
|
|
|
{ |
|
183
|
48
|
50
|
|
|
|
561
|
return $matcherCmdlinePair->[1] if $matcherCmdlinePair->[0]->qgrep($testName); |
|
184
|
|
|
|
|
|
|
} |
|
185
|
|
|
|
|
|
|
|
|
186
|
0
|
0
|
|
|
|
|
if (defined($self->{delegate})) |
|
187
|
|
|
|
|
|
|
{ |
|
188
|
0
|
|
|
|
|
|
return $self->{delegate}->getMapping($testName); |
|
189
|
|
|
|
|
|
|
} |
|
190
|
|
|
|
|
|
|
|
|
191
|
0
|
|
|
|
|
|
die("INTERNAL ERROR - should not reach this point!"); |
|
192
|
|
|
|
|
|
|
} |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
1; |