Class: OrigenTesters::ATP::Runner
Overview
This class is responsible for executing the given test flow based on a given set of runtime conditions. A subset of the input AST will be returned containing only the nodes that would be hit when the flow is executed under the given conditions.
Instance Method Summary
collapse
Methods inherited from Processor
#add_global_flag, #clean_flag, #extract_globals, #extract_volatiles, #global_flag?, #global_flags, #handler_missing, #process, #process_all, #volatile?, #volatile_flags
Instance Method Details
#clean_job(job) ⇒ Object
198
199
200
|
# File 'lib/origen_testers/atp/runner.rb', line 198
def clean_job(job)
[job].flatten.map { |j| j.to_s.upcase }
end
|
#completed? ⇒ Boolean
219
220
221
|
# File 'lib/origen_testers/atp/runner.rb', line 219
def completed?
@completed
end
|
#container ⇒ Object
230
231
232
|
# File 'lib/origen_testers/atp/runner.rb', line 230
def container
@containers.last
end
|
#failed_test_ids ⇒ Object
206
207
208
|
# File 'lib/origen_testers/atp/runner.rb', line 206
def failed_test_ids
@failed_test_ids ||= [@options[:failed_test_id] || @options[:failed_test_ids]].flatten.compact
end
|
#job ⇒ Object
202
203
204
|
# File 'lib/origen_testers/atp/runner.rb', line 202
def job
@options[:job].to_s.upcase if @options[:job]
end
|
#on_disable(node) ⇒ Object
174
175
176
|
# File 'lib/origen_testers/atp/runner.rb', line 174
def on_disable(node)
set_enables.delete(node.value)
end
|
#on_enable(node) ⇒ Object
170
171
172
|
# File 'lib/origen_testers/atp/runner.rb', line 170
def on_enable(node)
set_enables << node.value unless set_enables.include?(node.value)
end
|
#on_flow(node) ⇒ Object
23
24
25
26
27
28
|
# File 'lib/origen_testers/atp/runner.rb', line 23
def on_flow(node)
c = open_container do
process_all(node.children)
end
node.updated(nil, c)
end
|
#on_group(node) ⇒ Object
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
# File 'lib/origen_testers/atp/runner.rb', line 127
def on_group(node)
on_fail = node.find(:on_fail)
on_pass = node.find(:on_pass)
c = open_container do
@groups << true @groups_on_fail << on_fail
@groups_on_pass << on_pass
if on_fail
orig = @continue
@continue = !!on_fail.find(:continue)
process_all(node.children - [on_fail, on_pass])
@continue = orig
else
process_all(node.children - [on_fail, on_pass])
end
if !@groups.pop if on_fail
@continue = !!on_fail.find(:continue)
process_all(on_fail)
@continue = false
end
else
if on_pass
process_all(on_pass)
end
end
@groups_on_fail.pop
@groups_on_pass.pop
end
container << node.updated(nil, c)
end
|
#on_if_enabled(node) ⇒ Object
Also known as:
on_unless_enabled
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/origen_testers/atp/runner.rb', line 52
def on_if_enabled(node)
if @options[:evaluate_enables]
flag, *nodes = *node
flag = [flag].flatten
enabled = node.type == :if_enabled
active = flag.any? { |f| set_enables.include?(f) }
if (enabled && active) || (!enabled && !active)
process_all(nodes)
end
else
c = open_container do
process_all(node.children)
end
container << node.updated(nil, node.children.take(1) + c)
end
end
|
#on_if_failed(node) ⇒ Object
70
71
72
73
74
75
|
# File 'lib/origen_testers/atp/runner.rb', line 70
def on_if_failed(node)
id, *nodes = *node
if failed_test_ids.include?(id)
process_all(nodes)
end
end
|
#on_if_flag(node) ⇒ Object
Also known as:
on_unless_flag
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/origen_testers/atp/runner.rb', line 34
def on_if_flag(node)
if @options[:evaluate_flags]
flag, *nodes = *node
flag = [flag].flatten
enabled = node.type == :if_flag
active = flag.any? { |f| set_flags.include?(f) }
if (enabled && active) || (!enabled && !active)
process_all(nodes)
end
else
c = open_container do
process_all(node.children)
end
container << node.updated(nil, node.children.take(1) + c)
end
end
|
#on_if_job(node) ⇒ Object
Also known as:
on_unless_job
183
184
185
186
187
188
189
190
191
192
193
194
195
|
# File 'lib/origen_testers/atp/runner.rb', line 183
def on_if_job(node)
jobs, *nodes = *node
jobs = clean_job(jobs)
state = node.type == :if_job
unless job
fail 'Flow contains JOB-based conditions and no current JOB has been given!'
end
if state
process_all(node) if jobs.include?(job)
else
process_all(node) unless jobs.include?(job)
end
end
|
#on_if_passed(node) ⇒ Object
77
78
79
80
81
82
|
# File 'lib/origen_testers/atp/runner.rb', line 77
def on_if_passed(node)
id, *nodes = *node
unless failed_test_ids.include?(id)
process_all(nodes)
end
end
|
#on_log(node) ⇒ Object
Also known as:
on_render
178
179
180
|
# File 'lib/origen_testers/atp/runner.rb', line 178
def on_log(node)
container << node unless completed?
end
|
#on_name(node) ⇒ Object
30
31
32
|
# File 'lib/origen_testers/atp/runner.rb', line 30
def on_name(node)
container << node
end
|
#on_set_flag(node) ⇒ Object
166
167
168
|
# File 'lib/origen_testers/atp/runner.rb', line 166
def on_set_flag(node)
set_flags << node.to_a[0]
end
|
#on_set_result(node) ⇒ Object
159
160
161
162
163
164
|
# File 'lib/origen_testers/atp/runner.rb', line 159
def on_set_result(node)
unless @continue
container << node unless completed?
@completed = true if @options[:evaluate_set_result]
end
end
|
#on_test(node) ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
# File 'lib/origen_testers/atp/runner.rb', line 84
def on_test(node)
if id = node.find(:id)
id = id.to_a[0]
if failed_test_ids.include?(id)
node = node.add(node.updated(:failed, []))
failed = true
if n_on_fail = node.find(:on_fail)
node = node.remove(n_on_fail)
end
end
end
unless failed
if n_on_pass = node.find(:on_pass)
node = node.remove(n_on_pass)
end
end
unless completed?
container << node
process_all(n_on_fail) if n_on_fail
process_all(n_on_pass) if n_on_pass
end
if failed
if @groups.last
@groups.pop
@groups << false
end
if n = node.find(:on_fail)
orig = @continue
@continue ||= !!n.find(:continue)
process_all(n)
@continue = orig
end
else
if n = node.find(:on_pass)
process_all(n)
end
end
end
|
#open_container(c = []) ⇒ Object
223
224
225
226
227
228
|
# File 'lib/origen_testers/atp/runner.rb', line 223
def open_container(c = [])
@containers ||= []
@containers << c
yield
@containers.pop
end
|
#run(node, options = {}) ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/origen_testers/atp/runner.rb', line 7
def run(node, options = {})
options = {
evaluate_enables: true,
evaluate_flags: true,
evaluate_set_result: true
}.merge(options)
@options = options
@completed = false
@groups = []
@groups_on_fail = []
@groups_on_pass = []
node = Processors::AddIDs.new.run(node)
node = Processors::AddSetResult.new.run(node)
process(node)
end
|
#set_enables ⇒ Object
Returns an array of enabled flow flags
215
216
217
|
# File 'lib/origen_testers/atp/runner.rb', line 215
def set_enables
@set_enables ||= [@options[:enable] || @options[:enables]].flatten.compact
end
|
#set_flags ⇒ Object
210
211
212
|
# File 'lib/origen_testers/atp/runner.rb', line 210
def set_flags
@set_flags ||= []
end
|