multiple parameter set inheritance

41 views Asked by At

Is there currently a way to inherit from multiple parameter sets?

I have a use-case where I have a group of tests that all share some set of defaults, and then half of these tests share another set of defaults, and the other half share a different set.

My workaround so far has been:

  define_params :A_default do |p|
    params(:default)[:tm].each { |id, val| p.tm.send("#{id}=", val) }
    params(:A)[:tm].each { |id, val| p.tm.send("#{id}=", val) }
  end

  define_params :B_default do |p|
    params(:default)[:tm].each { |id, val| p.tm.send("#{id}=", val) }
    params(:B)[:tm].each { |id, val| p.tm.send("#{id}=", val) }
  end

Then my tests use inherit: :A_default or inherit: :B_default depending on the test.

I think ideally there'd be an api for multiple parent parameter sets if there isn't one currently, with some method of indicating the priority order (ie, if A and B parents conflict, who's value gets inherited).

Edit: Forgot to mention that there are also tests that inherit A or B as well, so defining A_default or B_default with their specific parameters and then inheriting default would still require me to define some parameters multiple times.

1

There are 1 answers

1
Ginty On BEST ANSWER

Multiple inheritance was not supported, so any answer would be a coding variation on your existing solution.

However, since it seems like a useful feature I added it, see - https://github.com/Origen-SDK/origen/pull/357