Reputation: 1586
I see that the Origen test_ids gem allows users to specify blocks as a config.
TestIds.configure :final_test do |config|
config.numbers do |bin, softbin|
(softbin * 10) + bin
end
end
Is it possible to reference any of the metadata passed to the test? For example, here are some test insertions in my flow file:
func :mytest, mode: :chain
func :mytest, mode: :jtag
Here is what I would like to do in the TestIds config:
TestIds.configure :final_test do |config|
config.numbers do |test_meta|
case test_meta[:mode]
when :chain
(softbin * 10) + bin
when :jtag
(softbin * 20) + bin
else
(softbin * 30) + bin
end
end
end
thx!
Upvotes: 1
Views: 59
Reputation: 83
I'll try to answer your question. My first ever at stackoverflow, hope it makes sense. Feel free to email me if you have more questions.
@rchitect-of-info Yes, you can. Few changes will be required to the test_ids plugin to support your needs.
Please look at the allocate method here in test_ids plugin: https://github.com/Origen-SDK/test_ids/blob/master/lib/test_ids/allocator.rb#L115
We will need to pass the options from the flow to the allocate_number method.
number['number'] ||= allocate_number(bin: bin['number'], softbin: softbin['number'], size: number_size, options: options)
number['size'] ||= number_size
Then, please look at the allocate_number method here in the test_ids plugin:
https://github.com/Origen-SDK/test_ids/blob/master/lib/test_ids/allocator.rb#L547
These callback options are what gets passed to config.numbers.
To access your metadata you would just pass the options along with bin and softbin here:
https://github.com/Origen-SDK/test_ids/blob/master/lib/test_ids/allocator.rb#L548
So the new callback would be
elsif callback = config.numbers.callback
callback.call(bin, softbin, options)
You would then be able to configure TestIds as
TestIds.configure :final_test do |config|
config.numbers do |bin, softbin, options|
case options[:mode]
when :chain
(softbin * 10) + bin
when :jtag
(softbin * 20) + bin
else
(softbin * 30) + bin
end
end
end
I am working on a similar update to test_ids, hopefully will be ready for review soon. My branch is currently a work in progress at https://github.com/priyavadan/test_ids/commits/change_config
Upvotes: 1