origen 0.2.6 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. checksums.yaml +4 -4
  2. data/bin/origen +3 -1
  3. data/config/boot.rb +1 -7
  4. data/config/commands.rb +0 -1
  5. data/config/version.rb +2 -2
  6. data/lib/c99/{j750_interface.rb → ate_interface.rb} +3 -11
  7. data/lib/c99/doc_interface.rb +1 -1
  8. data/lib/origen.rb +9 -30
  9. data/lib/origen/application.rb +10 -8
  10. data/lib/origen/application/configuration.rb +13 -26
  11. data/lib/origen/application/plugins.rb +122 -0
  12. data/lib/origen/application/plugins_manager.rb +16 -254
  13. data/lib/origen/application/release.rb +2 -2
  14. data/lib/origen/application/runner.rb +2 -4
  15. data/lib/origen/chips.rb +0 -0
  16. data/lib/origen/chips/chip.rb +0 -0
  17. data/lib/origen/chips/design_entry.rb +0 -0
  18. data/lib/origen/chips/doc_entry.rb +0 -0
  19. data/lib/origen/chips/note.rb +0 -0
  20. data/lib/origen/commands.rb +4 -44
  21. data/lib/origen/commands/compile.rb +1 -2
  22. data/lib/origen/commands/generate.rb +1 -1
  23. data/lib/origen/commands/interactive.rb +1 -2
  24. data/lib/origen/commands/plugin.rb +49 -56
  25. data/lib/origen/commands/program.rb +1 -1
  26. data/lib/origen/commands/rc.rb +2 -2
  27. data/lib/origen/commands/version.rb +2 -17
  28. data/lib/origen/commands_global.rb +3 -0
  29. data/lib/origen/file_handler.rb +10 -10
  30. data/lib/origen/generator.rb +1 -1
  31. data/lib/origen/generator/job.rb +1 -1
  32. data/lib/origen/generator/pattern.rb +2 -2
  33. data/lib/origen/generator/pattern_finder.rb +10 -9
  34. data/lib/origen/pins/pin.rb +0 -0
  35. data/lib/origen/regression_manager.rb +0 -0
  36. data/lib/origen/remote_manager.rb +2 -8
  37. data/lib/origen/revision_control/design_sync.rb +0 -0
  38. data/lib/origen/revision_control/git.rb +0 -0
  39. data/lib/origen/specs.rb +0 -0
  40. data/lib/origen/specs/checkers.rb +0 -0
  41. data/lib/origen/specs/creation_info.rb +0 -0
  42. data/lib/origen/specs/exhibit.rb +0 -0
  43. data/lib/origen/specs/spec.rb +0 -0
  44. data/lib/origen/utility.rb +0 -1
  45. data/lib/origen/utility/diff.rb +0 -0
  46. metadata +42 -119
  47. data/lib/origen/import_manager.rb +0 -596
  48. data/lib/origen/nvm.rb +0 -6
  49. data/lib/origen/nvm/block_array.rb +0 -72
  50. data/lib/origen/tester.rb +0 -56
  51. data/lib/origen/tester/api.rb +0 -277
  52. data/lib/origen/tester/bdm/bdm.rb +0 -25
  53. data/lib/origen/tester/doc/doc.rb +0 -226
  54. data/lib/origen/tester/doc/generator.rb +0 -126
  55. data/lib/origen/tester/doc/generator/flow.rb +0 -71
  56. data/lib/origen/tester/doc/generator/flow_line.rb +0 -203
  57. data/lib/origen/tester/doc/generator/test.rb +0 -68
  58. data/lib/origen/tester/doc/generator/test_group.rb +0 -66
  59. data/lib/origen/tester/doc/generator/tests.rb +0 -47
  60. data/lib/origen/tester/doc/model.rb +0 -162
  61. data/lib/origen/tester/generator.rb +0 -271
  62. data/lib/origen/tester/generator/flow_control_api.rb +0 -606
  63. data/lib/origen/tester/generator/identity_map.rb +0 -25
  64. data/lib/origen/tester/generator/placeholder.rb +0 -13
  65. data/lib/origen/tester/generator/test_numberer.rb +0 -25
  66. data/lib/origen/tester/interface.rb +0 -154
  67. data/lib/origen/tester/j750/files.rb +0 -45
  68. data/lib/origen/tester/j750/generator.rb +0 -203
  69. data/lib/origen/tester/j750/generator/flow.rb +0 -123
  70. data/lib/origen/tester/j750/generator/flow_line.rb +0 -288
  71. data/lib/origen/tester/j750/generator/patgroup.rb +0 -111
  72. data/lib/origen/tester/j750/generator/patgroups.rb +0 -41
  73. data/lib/origen/tester/j750/generator/patset.rb +0 -111
  74. data/lib/origen/tester/j750/generator/patsets.rb +0 -41
  75. data/lib/origen/tester/j750/generator/templates/flow.txt.erb +0 -9
  76. data/lib/origen/tester/j750/generator/templates/instances.txt.erb +0 -16
  77. data/lib/origen/tester/j750/generator/templates/patgroups.txt.erb +0 -8
  78. data/lib/origen/tester/j750/generator/templates/patsets.txt.erb +0 -10
  79. data/lib/origen/tester/j750/generator/test_instance.rb +0 -846
  80. data/lib/origen/tester/j750/generator/test_instance_group.rb +0 -60
  81. data/lib/origen/tester/j750/generator/test_instances.rb +0 -182
  82. data/lib/origen/tester/j750/j750.rb +0 -845
  83. data/lib/origen/tester/j750/j750_hpt.rb +0 -35
  84. data/lib/origen/tester/j750/parser.rb +0 -104
  85. data/lib/origen/tester/j750/parser/ac_spec.rb +0 -11
  86. data/lib/origen/tester/j750/parser/ac_specs.rb +0 -0
  87. data/lib/origen/tester/j750/parser/dc_spec.rb +0 -36
  88. data/lib/origen/tester/j750/parser/dc_specs.rb +0 -50
  89. data/lib/origen/tester/j750/parser/descriptions.rb +0 -340
  90. data/lib/origen/tester/j750/parser/flow.rb +0 -111
  91. data/lib/origen/tester/j750/parser/flow_line.rb +0 -207
  92. data/lib/origen/tester/j750/parser/flows.rb +0 -23
  93. data/lib/origen/tester/j750/parser/pattern_set.rb +0 -94
  94. data/lib/origen/tester/j750/parser/pattern_sets.rb +0 -33
  95. data/lib/origen/tester/j750/parser/test_instance.rb +0 -322
  96. data/lib/origen/tester/j750/parser/test_instances.rb +0 -26
  97. data/lib/origen/tester/j750/parser/timeset.rb +0 -15
  98. data/lib/origen/tester/j750/parser/timesets.rb +0 -0
  99. data/lib/origen/tester/jlink/jlink.rb +0 -33
  100. data/lib/origen/tester/parser.rb +0 -24
  101. data/lib/origen/tester/parser/description_lookup.rb +0 -64
  102. data/lib/origen/tester/parser/searchable_array.rb +0 -32
  103. data/lib/origen/tester/parser/searchable_hash.rb +0 -32
  104. data/lib/origen/tester/time.rb +0 -338
  105. data/lib/origen/tester/timing.rb +0 -253
  106. data/lib/origen/tester/ultraflex/files.rb +0 -45
  107. data/lib/origen/tester/ultraflex/generator.rb +0 -200
  108. data/lib/origen/tester/ultraflex/generator/flow.rb +0 -119
  109. data/lib/origen/tester/ultraflex/generator/flow_line.rb +0 -269
  110. data/lib/origen/tester/ultraflex/generator/patgroup.rb +0 -111
  111. data/lib/origen/tester/ultraflex/generator/patgroups.rb +0 -41
  112. data/lib/origen/tester/ultraflex/generator/patset.rb +0 -111
  113. data/lib/origen/tester/ultraflex/generator/patsets.rb +0 -41
  114. data/lib/origen/tester/ultraflex/generator/templates/flow.txt.erb +0 -9
  115. data/lib/origen/tester/ultraflex/generator/templates/instances.txt.erb +0 -16
  116. data/lib/origen/tester/ultraflex/generator/templates/patgroups.txt.erb +0 -8
  117. data/lib/origen/tester/ultraflex/generator/templates/patsets.txt.erb +0 -10
  118. data/lib/origen/tester/ultraflex/generator/test_instance.rb +0 -622
  119. data/lib/origen/tester/ultraflex/generator/test_instance_group.rb +0 -60
  120. data/lib/origen/tester/ultraflex/generator/test_instances.rb +0 -174
  121. data/lib/origen/tester/ultraflex/parser.rb +0 -104
  122. data/lib/origen/tester/ultraflex/parser/ac_spec.rb +0 -11
  123. data/lib/origen/tester/ultraflex/parser/ac_specs.rb +0 -0
  124. data/lib/origen/tester/ultraflex/parser/dc_spec.rb +0 -36
  125. data/lib/origen/tester/ultraflex/parser/dc_specs.rb +0 -50
  126. data/lib/origen/tester/ultraflex/parser/descriptions.rb +0 -342
  127. data/lib/origen/tester/ultraflex/parser/flow.rb +0 -111
  128. data/lib/origen/tester/ultraflex/parser/flow_line.rb +0 -207
  129. data/lib/origen/tester/ultraflex/parser/flows.rb +0 -23
  130. data/lib/origen/tester/ultraflex/parser/pattern_set.rb +0 -94
  131. data/lib/origen/tester/ultraflex/parser/pattern_sets.rb +0 -33
  132. data/lib/origen/tester/ultraflex/parser/test_instance.rb +0 -262
  133. data/lib/origen/tester/ultraflex/parser/test_instances.rb +0 -26
  134. data/lib/origen/tester/ultraflex/parser/timeset.rb +0 -15
  135. data/lib/origen/tester/ultraflex/parser/timesets.rb +0 -0
  136. data/lib/origen/tester/ultraflex/ultraflex.rb +0 -759
  137. data/lib/origen/tester/v93k/generator.rb +0 -80
  138. data/lib/origen/tester/v93k/generator/flow.rb +0 -63
  139. data/lib/origen/tester/v93k/generator/flow_node.rb +0 -17
  140. data/lib/origen/tester/v93k/generator/flow_node/print.rb +0 -10
  141. data/lib/origen/tester/v93k/generator/pattern.rb +0 -16
  142. data/lib/origen/tester/v93k/generator/pattern_master.rb +0 -54
  143. data/lib/origen/tester/v93k/generator/templates/_test_method.txt.erb +0 -6
  144. data/lib/origen/tester/v93k/generator/templates/_test_suite.txt.erb +0 -11
  145. data/lib/origen/tester/v93k/generator/templates/template.flow.erb +0 -121
  146. data/lib/origen/tester/v93k/generator/templates/template.pmfl.erb +0 -9
  147. data/lib/origen/tester/v93k/generator/test_function.rb +0 -103
  148. data/lib/origen/tester/v93k/generator/test_functions.rb +0 -79
  149. data/lib/origen/tester/v93k/generator/test_method.rb +0 -46
  150. data/lib/origen/tester/v93k/generator/test_methods.rb +0 -75
  151. data/lib/origen/tester/v93k/generator/test_suite.rb +0 -54
  152. data/lib/origen/tester/v93k/generator/test_suites.rb +0 -65
  153. data/lib/origen/tester/v93k/v93k.rb +0 -420
  154. data/lib/origen/tester/vector.rb +0 -86
  155. data/lib/origen/tester/vector_generator.rb +0 -637
  156. data/lib/origen/tester/vector_pipeline.rb +0 -150
  157. data/lib/origen/utility/design_sync.rb +0 -494
  158. data/lib/origen/version_checker.rb +0 -117
@@ -1,606 +0,0 @@
1
- module Origen
2
- module Tester
3
- module Generator
4
- module FlowControlAPI
5
- # Flow control methods related to flow context
6
- FLOW_METHODS = [
7
- # Methods in arrays are aliases, the primary name is the first one
8
- [:if_enable, :if_enabled, :enable, :enabled],
9
- [:unless_enable, :unless_enabled],
10
- [:if_job, :if_jobs],
11
- [:unless_job, :unless_jobs]
12
- ]
13
-
14
- # Flow control methods related to a relationship with another test
15
- RELATION_METHODS = [
16
- # Methods in arrays are aliases, the primary name is the first one
17
- :if_ran,
18
- :unless_ran,
19
- [:if_failed, :unless_passed],
20
- [:if_passed, :unless_failed],
21
- [:if_any_passed, :unless_all_failed],
22
- [:if_all_passed, :unless_any_failed],
23
- [:if_any_failed, :unless_all_passed],
24
- [:if_all_failed, :unless_any_passed]
25
- ]
26
-
27
- # Returns true if the test context generated from the supplied options + existing context
28
- # wrappers is different from that which was applied to the previous test.
29
- def context_changed?(options = {})
30
- current_context[:hash_code] != summarize_context(options)[:hash_code]
31
- end
32
-
33
- # @api private
34
- def save_context(options = {})
35
- # If the test has requested to use the current context...
36
- if options[:context] == :current
37
- replace_context_with_current(options)
38
- else
39
- @current_context = summarize_context(options)
40
- options.merge(@current_context[:context])
41
- end
42
- end
43
-
44
- # Returns a hash representing the current context, that is the context that was applied
45
- # to the last test.
46
- #
47
- # The hash contains two items:
48
- #
49
- # * :context contains a hash that summarises the flow control options that have been
50
- # used, for example it may contain something like: :if_enable => "data_collection"
51
- # * :hash_code returns a hash-code for the values contained in the :context arrary. Any
52
- # two equivalent contexts will have the same :hash_code, therefore this can be used
53
- # to easily check the equivalence of any two contexts.
54
- def current_context
55
- @current_context ||= save_context
56
- end
57
-
58
- # @api private
59
- #
60
- # Removes any context options from the given options hash and merges in the current
61
- # context
62
- def replace_context_with_current(options)
63
- options = options.merge({})
64
- [FLOW_METHODS, RELATION_METHODS].flatten.each do |m|
65
- options.delete(m)
66
- end
67
- options.merge(current_context[:context])
68
- end
69
-
70
- # Returns a hash like that returned by current_context based on the given set of options +
71
- # existing context wrappers.
72
- def summarize_context(options = {})
73
- code = []
74
- context = {}
75
- (FLOW_METHODS + RELATION_METHODS).each do |m|
76
- primary = m.is_a?(Array) ? m.first : m
77
- val = false
78
- [m].flatten.each do |m|
79
- if options[m]
80
- val = options[m]
81
- elsif instance_variable_get("@#{m}_block")
82
- val = instance_variable_get("@#{m}_block")
83
- end
84
- end
85
- if val
86
- code << primary
87
- code << val
88
- context[primary] = val
89
- end
90
- end
91
- { hash_code: code.flatten.hash, context: context }
92
- end
93
-
94
- # All tests generated within the given block will be assigned the given enable word.
95
- #
96
- # If a test encountered within the block already has another enable word assigned to it then
97
- # an error will be raised.
98
- def if_enable(word, _options = {})
99
- @if_enable_block = word
100
- yield word
101
- @if_enable_block = nil
102
- end
103
- alias_method :if_enabled, :if_enable
104
-
105
- # All tests generated will not run unless the given enable word is asserted.
106
- def unless_enable(word, options = {})
107
- @unless_enable_block = word unless options[:or]
108
- yield word
109
- @unless_enable_block = nil
110
- end
111
- alias_method :unless_enabled, :unless_enable
112
-
113
- # All tests generated within the given block will be enabled only for the given jobs.
114
- def if_job(*jobs)
115
- jobs = jobs.flatten
116
- @if_job_block = @if_job_block ? @if_job_block + jobs : jobs
117
- yield
118
- @if_job_block = nil
119
- end
120
- alias_method :if_jobs, :if_job
121
-
122
- # All tests generated within the given block will be enabled only for the given jobs.
123
- def unless_job(*jobs)
124
- jobs = jobs.flatten
125
- @unless_job_block = @unless_job_block ? @unless_job_block + jobs : jobs
126
- yield
127
- @unless_job_block = nil
128
- end
129
- alias_method :unless_jobs, :unless_job
130
-
131
- # All tests generated within the given block will only run if the given test id has also
132
- # run earlier in the flow
133
- def if_ran(test_id, options = {})
134
- test_id = Origen.interface.filter_id(test_id, options)
135
- return if options.key?(:if) && !options[:if]
136
- return if options.key?(:unless) && options[:unless]
137
- if @if_ran_block
138
- fail 'Sorry but nesting of if_ran is not currently supported!'
139
- end
140
- @if_ran_block = test_id
141
- yield
142
- @if_ran_block = nil
143
- end
144
-
145
- # All tests generated within the given block will only run if the given test id has not
146
- # run earlier in the flow
147
- def unless_ran(test_id, options = {})
148
- test_id = Origen.interface.filter_id(test_id, options)
149
- return if options.key?(:if) && !options[:if]
150
- return if options.key?(:unless) && options[:unless]
151
- if @unless_ran_block
152
- fail 'Sorry but nesting of unless_ran is not currently supported!'
153
- end
154
- @unless_ran_block = test_id
155
- yield
156
- @unless_ran_block = nil
157
- end
158
-
159
- # All tests generated within the given block will only run if the given test id has
160
- # failed earlier in the flow
161
- def if_failed(test_id, options = {})
162
- test_id = Origen.interface.filter_id(test_id, options)
163
- return if options.key?(:if) && !options[:if]
164
- return if options.key?(:unless) && options[:unless]
165
- if @if_failed_block
166
- fail 'Sorry but nesting of if_failed is not currently supported!'
167
- end
168
- @if_failed_block = test_id
169
- yield
170
- @if_failed_block = nil
171
- end
172
- alias_method :unless_passed, :if_failed
173
-
174
- # All tests generated within the given block will only run if the given test id has
175
- # passed earlier in the flow
176
- def if_passed(test_id, options = {})
177
- test_id = Origen.interface.filter_id(test_id, options)
178
- return if options.key?(:if) && !options[:if]
179
- return if options.key?(:unless) && options[:unless]
180
- if @if_passed_block
181
- fail 'Sorry but nesting of if_passed is not currently supported!'
182
- end
183
- @if_passed_block = test_id
184
- yield
185
- @if_passed_block = nil
186
- end
187
- alias_method :unless_failed, :if_passed
188
-
189
- # All tests generated within the given block will only run if the given test id has
190
- # passed ON ANY SITE earlier in the flow
191
- def if_any_passed(test_id, options = {})
192
- test_id = Origen.interface.filter_id(test_id, options)
193
- return if conditionally_deactivated?(options)
194
- if @if_any_passed_block
195
- fail 'Sorry but nesting of if_any_passed is not currently supported!'
196
- end
197
- @if_any_passed_block = test_id
198
- yield
199
- @if_any_passed_block = nil
200
- end
201
- alias_method :unless_all_failed, :if_any_passed
202
-
203
- # All tests generated within the given block will only run if the given test id has
204
- # passed ON ALL SITES earlier in the flow
205
- def if_all_passed(test_id, options = {})
206
- test_id = Origen.interface.filter_id(test_id, options)
207
- return if conditionally_deactivated?(options)
208
- if @if_all_passed_block
209
- fail 'Sorry but nesting of if_all_passed is not currently supported!'
210
- end
211
- @if_all_passed_block = test_id
212
- yield
213
- @if_all_passed_block = nil
214
- end
215
- alias_method :unless_any_failed, :if_all_passed
216
-
217
- # All tests generated within the given block will only run if the given test id has
218
- # failed ON ANY SITE earlier in the flow
219
- def if_any_failed(test_id, options = {})
220
- test_id = Origen.interface.filter_id(test_id, options)
221
- return if conditionally_deactivated?(options)
222
- if @if_any_failed_block
223
- fail 'Sorry but nesting of if_any_failed is not currently supported!'
224
- end
225
- @if_any_failed_block = test_id
226
- yield
227
- @if_any_failed_block = nil
228
- end
229
- alias_method :unless_all_passed, :if_any_failed
230
-
231
- # All tests generated within the given block will only run if the given test id has
232
- # failed ON ALL SITES earlier in the flow
233
- def if_all_failed(test_id, options = {})
234
- test_id = Origen.interface.filter_id(test_id, options)
235
- return if conditionally_deactivated?(options)
236
- if @if_all_failed_block
237
- fail 'Sorry but nesting of if_all_failed is not currently supported!'
238
- end
239
- @if_all_failed_block = test_id
240
- yield
241
- @if_all_failed_block = nil
242
- end
243
- alias_method :unless_any_passed, :if_all_failed
244
-
245
- def conditionally_deactivated?(options)
246
- (options.key?(:if) && !options[:if]) ||
247
- (options.key?(:unless) && options[:unless])
248
- end
249
-
250
- def find_by_id(id, options = {}) # :nodoc:
251
- options = {
252
- search_other_flows: true
253
- }.merge(options)
254
- # Look within the current flow for a match first
255
- t = identity_map[id.to_sym]
256
- return t if t
257
- # If no match then look across other flow modules for a match
258
- # This currently returns the first match, should it raise an error on multiple?
259
- if options[:search_other_flows]
260
- Origen.interface.flow_generators.any? do |flow|
261
- t = flow.find_by_id(id, search_other_flows: false)
262
- end
263
- end
264
- t
265
- end
266
-
267
- def identity_map # :nodoc:
268
- @identity_map ||= {}
269
- end
270
-
271
- # If a class that includes this module has a finalize method it must
272
- # call apply_relationships
273
- def finalize(_options = {}) # :nodoc:
274
- apply_relationships
275
- end
276
-
277
- def apply_relationships # :nodoc:
278
- if @relationships
279
- @relationships.each do |rel|
280
- t = find_by_id(rel[:target_id])
281
- fail "Test not found with ID: #{rel[:target_id]}, referenced in flow: #{filename}" unless t
282
- t.id = rel[:target_id]
283
- confirm_valid_context(t, rel[:dependent])
284
- case rel[:type]
285
- # The first cases here contain J750 logic, these should be replaced
286
- # with the call method style used for the later cases when time permits.
287
- when :failed
288
- if rel[:dependent].respond_to?(:run_if_failed)
289
- rel[:dependent].run_if_failed(rel[:target_id])
290
- else
291
- t.continue_on_fail
292
- flag = t.set_flag_on_fail
293
- rel[:dependent].flag_true = flag
294
- end
295
- when :passed
296
- if rel[:dependent].respond_to?(:run_if_passed)
297
- rel[:dependent].run_if_passed(rel[:target_id])
298
- else
299
- t.continue_on_fail
300
- flag = t.set_flag_on_pass
301
- rel[:dependent].flag_true = flag
302
- end
303
- when :if_ran, :unless_ran
304
- if rel[:type] == :if_ran
305
- if rel[:dependent].respond_to?(:run_if_ran)
306
- rel[:dependent].run_if_ran(rel[:target_id])
307
- else
308
- # t.continue_on_fail
309
- flag = t.set_flag_on_ran
310
- rel[:dependent].flag_true = flag
311
- end
312
- else
313
- if rel[:dependent].respond_to?(:run_unless_ran)
314
- rel[:dependent].run_unless_ran(rel[:target_id])
315
- else
316
- # t.continue_on_fail
317
- flag = t.set_flag_on_ran
318
- rel[:dependent].flag_clear = flag
319
- end
320
- end
321
- when :any_passed
322
- rel[:dependent].run_if_any_passed(t)
323
- when :all_passed
324
- rel[:dependent].run_if_all_passed(t)
325
- when :any_failed
326
- rel[:dependent].run_if_any_failed(t)
327
- when :all_failed
328
- rel[:dependent].run_if_all_failed(t)
329
- else
330
- fail 'Unknown relationship type!'
331
- end
332
- end
333
- @relationships = nil
334
- end
335
- end
336
-
337
- def confirm_valid_context(_test, _dependent) # :nodoc:
338
- # TODO: Add some validation checks here, for example make sure the dependent
339
- # executes in the same job(s) as the test, otherwise the dependent will
340
- # never be hit and will cause a validation error.
341
- end
342
-
343
- def record_id(test, options = {})
344
- if options[:id]
345
- @@existing_ids ||= []
346
- if @@existing_ids.include?(options[:id].to_sym)
347
- fail "The ID '#{test.id}' is not unique, it has already been assigned!"
348
- else
349
- @@existing_ids << options[:id].to_sym
350
- end
351
- identity_map[options[:id].to_sym] = test
352
- end
353
- end
354
-
355
- # @api private
356
- def at_run_start
357
- @@existing_ids = nil
358
- @@labels = nil
359
- end
360
- alias_method :reset_globals, :at_run_start
361
-
362
- # As generation of render and imports is not linear its possible that the test being
363
- # referenced does not exist in the collection yet.
364
- # Therefore the required relationship will be recorded for now and applied later upon
365
- # closing the generator at which point the complete final collection will be available.
366
- #
367
- # Note - as of v2.0.1.dev64 the above is no longer true - imports are generated linearly.
368
- # Therefore parent test should always already exist and it is possible that this relationship
369
- # handling could be cleaned up considerably.
370
- #
371
- # However we should keep it around for now as it may come in useful when other tester
372
- # platforms are supported in the future.
373
- def track_relationships(test_options = {}) # :nodoc:
374
- [:id, RELATION_METHODS].flatten.each do |id|
375
- if test_options[id]
376
- test_options[id] = Origen.interface.filter_id(test_options[id], test_options)
377
- end
378
- end
379
- options = extract_relation_options!(test_options)
380
- current_test = yield test_options
381
- record_id(current_test, test_options)
382
- @relationships ||= []
383
- target_id = options[:if_failed] || options[:unless_passed] || @if_failed_block
384
- if target_id
385
- @relationships << {
386
- type: :failed,
387
- target_id: target_id,
388
- dependent: current_test
389
- }
390
- end
391
- target_id = options[:if_passed] || options[:unless_failed] || @if_passed_block
392
- if target_id
393
- @relationships << {
394
- type: :passed,
395
- target_id: target_id,
396
- dependent: current_test
397
- }
398
- end
399
- target_id = options.delete(:if_ran) || @if_ran_block
400
- if target_id
401
- @relationships << {
402
- type: :if_ran,
403
- target_id: target_id,
404
- dependent: current_test
405
- }
406
- end
407
- target_id = options.delete(:unless_ran) || @unless_ran_block
408
- if target_id
409
- @relationships << {
410
- type: :unless_ran,
411
- target_id: target_id,
412
- dependent: current_test
413
- }
414
- end
415
- target_id = options[:if_any_passed] || options[:unless_all_failed] || @if_any_passed_block
416
- if target_id
417
- @relationships << {
418
- type: :any_passed,
419
- target_id: target_id,
420
- dependent: current_test
421
- }
422
- end
423
- target_id = options[:if_all_passed] || options[:unless_any_failed] || @if_all_passed_block
424
- if target_id
425
- @relationships << {
426
- type: :all_passed,
427
- target_id: target_id,
428
- dependent: current_test
429
- }
430
- end
431
- target_id = options[:if_any_failed] || options[:unless_all_passed] || @if_any_failed_block
432
- if target_id
433
- @relationships << {
434
- type: :any_failed,
435
- target_id: target_id,
436
- dependent: current_test
437
- }
438
- end
439
- target_id = options[:if_all_failed] || options[:unless_any_passed] || @if_all_failed_block
440
- if target_id
441
- @relationships << {
442
- type: :all_failed,
443
- target_id: target_id,
444
- dependent: current_test
445
- }
446
- end
447
- if test_options[:context] == :current # Context has already been applied
448
- current_test
449
- else
450
- apply_current_context!(current_test)
451
- end
452
- end
453
-
454
- def apply_current_context!(line) # :nodoc:
455
- if @if_enable_block
456
- if line.enable && line.enable != @if_enable_block
457
- fail "Cannot apply enable word '#{@if_enable_block}' to '#{line.parameter}', it already has '#{line.enable}'"
458
- else
459
- line.enable = @if_enable_block
460
- end
461
- end
462
- if @unless_enable_block
463
- line.unless_enable = @unless_enable_block
464
- end
465
- line.if_job = @if_job_block if @if_job_block
466
- line.unless_job = @unless_job_block if @unless_job_block
467
- line
468
- end
469
-
470
- # Removes any flow relationship options from given hash and returns them
471
- # in a new hash
472
- def extract_relation_options!(options) # :nodoc:
473
- opts = {}
474
- RELATION_METHODS.flatten.each do |o|
475
- opts[o] = options.delete(o)
476
- end
477
- opts
478
- end
479
-
480
- def extract_flow_control_options!(options)
481
- opts = {}
482
- FLOW_METHODS.flatten.each do |o|
483
- if options.key?(o)
484
- opts[o] = options.delete(o)
485
- end
486
- end
487
- opts
488
- end
489
-
490
- def generate_unique_label(id = nil)
491
- id = 'label' if !id || id == ''
492
- label = "#{Origen.interface.app_identifier}_#{id}"
493
- label.gsub!(' ', '_')
494
- label.upcase!
495
- @@labels ||= {}
496
- @@labels[Origen.tester.class] ||= {}
497
- @@labels[Origen.tester.class][label] ||= 0
498
- @@labels[Origen.tester.class][label] += 1
499
- "#{label}_#{@@labels[Origen.tester.class][label]}"
500
- end
501
-
502
- module Interface
503
- # Implement this method in your application interface if you want to
504
- # sanitize all ID references used in the flow control API.
505
- # For example you could use this to append a flow name prefix to every
506
- # ID reference within a flow which can help with ID duplication problems
507
- # when flow snippets are re-used.
508
- def filter_id(id, _options = {})
509
- id
510
- end
511
-
512
- def extract_relation_options!(*args)
513
- flow.extract_relation_options!(*args)
514
- end
515
-
516
- def extract_flow_control_options!(*args)
517
- flow.extract_flow_control_options!(*args)
518
- end
519
-
520
- # Alias for flow#if_enable
521
- def if_enable(*args, &block)
522
- flow.if_enable(*args, &block)
523
- end
524
- alias_method :if_enabled, :if_enable
525
-
526
- # Alias for flow#unless_enable
527
- def unless_enable(*args, &block)
528
- flow.unless_enable(*args, &block)
529
- end
530
- alias_method :unless_enabled, :unless_enable
531
-
532
- # Alias for flow#if_job
533
- def if_job(*args, &block)
534
- flow.if_job(*args, &block)
535
- end
536
-
537
- # Alias for flow#unless_job
538
- def unless_job(*args, &block)
539
- flow.unless_job(*args, &block)
540
- end
541
-
542
- # Alias for flow#unless_ran
543
- def unless_ran(*args, &block)
544
- flow.unless_ran(*args, &block)
545
- end
546
-
547
- # Alias for flow#if_ran
548
- def if_ran(*args, &block)
549
- flow.if_ran(*args, &block)
550
- end
551
-
552
- # Alias for flow#if_failed
553
- def if_failed(*args, &block)
554
- flow.if_failed(*args, &block)
555
- end
556
- alias_method :unless_passed, :if_failed
557
-
558
- # Alias for flow#if_passed
559
- def if_passed(*args, &block)
560
- flow.if_passed(*args, &block)
561
- end
562
- alias_method :unless_failed, :if_passed
563
-
564
- # Alias for flow#if_any_passed
565
- def if_any_passed(*args, &block)
566
- flow.if_any_passed(*args, &block)
567
- end
568
- alias_method :unless_all_failed, :if_any_passed
569
-
570
- # Alias for flow#if_all_passed
571
- def if_all_passed(*args, &block)
572
- flow.if_all_passed(*args, &block)
573
- end
574
- alias_method :unless_any_failed, :if_all_passed
575
-
576
- # Alias for flow#if_any_failed
577
- def if_any_failed(*args, &block)
578
- flow.if_any_failed(*args, &block)
579
- end
580
- alias_method :unless_all_passed, :if_any_failed
581
-
582
- # Alias for flow#if_all_failed
583
- def if_all_failed(*args, &block)
584
- flow.if_all_failed(*args, &block)
585
- end
586
- alias_method :unless_any_passed, :if_all_failed
587
-
588
- # Alias for flow#skip
589
- def skip(*args, &block)
590
- flow.skip(*args, &block)
591
- end
592
-
593
- # Alias for flow#current_context
594
- def current_context(*args, &block)
595
- flow.current_context(*args, &block)
596
- end
597
-
598
- # Alias for flow#context_changed?
599
- def context_changed?(*args, &block)
600
- flow.context_changed?(*args, &block)
601
- end
602
- end
603
- end
604
- end
605
- end
606
- end