-
Notifications
You must be signed in to change notification settings - Fork 15
Description
I have a component that the input ports are dynamic.
The ports are created on the configure state according to component configs. While doing the unit tests for this component, I realized that even after the configuration of the ports are done, i could not find the proper interface to access the inputs.
For instance, considering that I have: in_x and in_y as names for my dynamic inputs, after configuring the inputs, i’m not able to find the task.in_x_port and task.in_y_port (or the correspondent) to work with them like a "static" port would have.
I try to create the port on the test with : task.orocos_task.create_input_port('in_x', '/type')
But i got:
NoMethodError: undefined method create_input_port' for #<Orocos::TaskContext: Orocos::TaskContext//task_under_test>
For now, the only way i could find to access the created input was by using:
task.orocos_task.in_x.write(samples_in)
But I guess this is not a good practice and in some tests a small amount of the samples written never arrive what makes the approach below not reliable.
output = expect_execution { task.orocos_task.in_x.write(samples_in)}
.to { have_one_new_sample task.out_port }
The way i managed to make it work properly right now, is by using the following approach:
reader = task.orocos_task.out.reader
task.orocos_task.in_x.write samples_in
output = expect_execution.to { have_one_new_sample reader }
Do you have any guideline on how i should properly access a dynamic input port using the syskit orogen-test??