Class: Syskit::Test::TaskContextTest
- Inherits:
-
ComponentTest
- Object
- Roby::Test::Spec
- Spec
- ComponentTest
- Syskit::Test::TaskContextTest
- Defined in:
- lib/syskit/test/task_context_test.rb
Overview
Base class for all spec contexts whose subject is a task context model
Direct Known Subclasses
Class Method Summary collapse
-
.ensure_can_deploy_subject_syskit_model(test, app) ⇒ Object
Automatically skip tests for which the task model under test is not available.
-
.it_should_be_configurable ⇒ Object
deprecated
Deprecated.
use instead it { is_configurable }
-
.roby_should_run(test, app) ⇒ Object
Overloaded from Roby to call TaskContextTest.ensure_can_deploy_subject_syskit_model.
Instance Method Summary collapse
-
#assert_is_configurable(task_model = subject_syskit_model) ⇒ Object
Tests that the task can be configured.
-
#deploy_subject_syskit_model ⇒ Object
Define a deployment for the task model under test.
-
#is_configurable(task_model = subject_syskit_model) ⇒ Object
Spec-style variant to #assert_is_configurable.
-
#setup ⇒ Object
Overloaded to automatically call #deploy_subject_syskit_model.
-
#subject_syskit_model ⇒ Object
Returns the task model under test.
Methods inherited from ComponentTest
Methods included from NetworkManipulation
#__syskit_root_components, #normalize_instanciation_models, #resolve_orocos_writer, #syskit_configure, #syskit_configure_and_start, #syskit_default_stub_name, #syskit_deploy, #syskit_deploy_and_configure, #syskit_deploy_configure_and_start, #syskit_engine_resolve_handle_plan_export, #syskit_export_to_svg, #syskit_generate_network, #syskit_guard_against_configure, #syskit_guard_against_start_and_configure, #syskit_prepare_configure, #syskit_prepare_start, #syskit_protect_configuration_manager, #syskit_start, #syskit_start_all_execution_agents, #syskit_start_execution_agents, #syskit_stub, #syskit_stub_and_deploy, #syskit_stub_attached_device, #syskit_stub_com_bus, #syskit_stub_component, #syskit_stub_composition_requirements, #syskit_stub_conf, #syskit_stub_configured_deployment, #syskit_stub_deploy_and_configure, #syskit_stub_deploy_configure_and_start, #syskit_stub_deployment, #syskit_stub_deployment_model, #syskit_stub_device, #syskit_stub_driver_model_for, #syskit_stub_model_id, #syskit_stub_network, #syskit_stub_network_abstract_component, #syskit_stub_network_deployment, #syskit_stub_placeholder, #syskit_stub_required_devices, #syskit_stub_requirements, #syskit_stub_resolves_remote_tasks=, #syskit_stub_resolves_remote_tasks?, #syskit_stub_task_context_model, #syskit_stub_task_context_requirements, #syskit_wait_ready, #syskit_write, #teardown, #use_deployment, #use_ruby_tasks, #use_unmanaged_task
Methods inherited from Spec
#plan, subject_syskit_model, #syskit_stub_attached_device_model, #syskit_stub_driver_model, #teardown, #teardown_registered_plans, use_syskit_model
Methods included from Base
#assert_has_no_new_sample, #assert_has_one_new_sample, #plug_connection_management, #plug_requirement_modifications, #stub_type, #teardown, #unplug_connection_management, #unplug_requirement_modifications
Class Method Details
.ensure_can_deploy_subject_syskit_model(test, app) ⇒ Object
Automatically skip tests for which the task model under test is not available
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/syskit/test/task_context_test.rb', line 80 def self.ensure_can_deploy_subject_syskit_model(test, app) orogen_model = subject_syskit_model.orogen_model if app.simulation? begin ruby_task = Orocos::RubyTasks::TaskContext.new( "spec#{object_id}", model: orogen_model) ruby_task.dispose rescue ::Exception => e test.skip("#{test.__full_name__} cannot run: #{e.}") end elsif orogen_model.abstract? test.skip("#{test.__full_name__} cannot run: #{orogen_model.name} is abstract and we're in live mode") else project_name = orogen_model.project.name if !Orocos.default_pkgconfig_loader.has_project?(project_name) test.skip("#{test.__full_name__} cannot run: oroGen project #{project_name} is not available") end end end |
.it_should_be_configurable ⇒ Object
use instead it { is_configurable }
43 44 45 46 47 |
# File 'lib/syskit/test/task_context_test.rb', line 43 def self.it_should_be_configurable Test.warn "it_should_be_configurable is deprecated, use" Test.warn " it { is_configurable } instead" it { is_configurable } end |
.roby_should_run(test, app) ⇒ Object
Overloaded from Roby to call ensure_can_deploy_subject_syskit_model
102 103 104 105 |
# File 'lib/syskit/test/task_context_test.rb', line 102 def self.roby_should_run(test, app) super ensure_can_deploy_subject_syskit_model(test, app) end |
Instance Method Details
#assert_is_configurable(task_model = subject_syskit_model) ⇒ Object
Tests that the task can be configured
The argument can be any instance requirement, so that one can e.g. test with particular arguments applied.
62 63 64 |
# File 'lib/syskit/test/task_context_test.rb', line 62 def assert_is_configurable(task_model = subject_syskit_model) syskit_deploy_and_configure(task_model) end |
#deploy_subject_syskit_model ⇒ Object
Define a deployment for the task model under test
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/syskit/test/task_context_test.rb', line 12 def deploy_subject_syskit_model task_context_m = self.class.subject_syskit_model.concrete_model if task_context_m.orogen_model.abstract? # This task context is abstract, i.e. does not have a # default deployment, and therefore cannot be deployed. Stub # it if we are in stub mode, skip the test otherwise if !app.simulation? raise RuntimeError, "cannot deploy the abstract task context model #{task_context_m} in live mode" end task_context_m.abstract = false process_name = OroGen::Spec::Project.default_deployment_name(task_context_m.orogen_model.name) syskit_stub_deployment_model(nil, process_name) do task process_name, task_context_m.orogen_model end else use_deployment(task_context_m => 'task_under_test').first end end |
#is_configurable(task_model = subject_syskit_model) ⇒ Object
Spec-style variant to #assert_is_configurable
74 75 76 |
# File 'lib/syskit/test/task_context_test.rb', line 74 def is_configurable(task_model = subject_syskit_model) assert_is_configurable(task_model) end |
#setup ⇒ Object
Overloaded to automatically call #deploy_subject_syskit_model
6 7 8 9 |
# File 'lib/syskit/test/task_context_test.rb', line 6 def setup super @deployed_subject_syskit_model = deploy_subject_syskit_model end |
#subject_syskit_model ⇒ Object
Returns the task model under test
34 35 36 37 38 39 |
# File 'lib/syskit/test/task_context_test.rb', line 34 def subject_syskit_model model = self.class.subject_syskit_model model = syskit_stub_required_devices(model) model.prefer_deployed_tasks(@deployed_subject_syskit_model) model end |