diff --git a/lib/syskit/network_generation/async.rb b/lib/syskit/network_generation/async.rb index 67404a980..a78d98594 100644 --- a/lib/syskit/network_generation/async.rb +++ b/lib/syskit/network_generation/async.rb @@ -119,9 +119,6 @@ def cancelled? class InvalidState < RuntimeError; end - SystemNetworkPlanApplyResult = - Struct.new :fulfilled, :instances, :errors, keyword_init: true - # Apply the result of the generation # # @return [Boolean] true if the result has been applied, and false diff --git a/lib/syskit/network_generation/resolution_error_handler.rb b/lib/syskit/network_generation/resolution_error_handler.rb index 1145aa55c..040157cf5 100644 --- a/lib/syskit/network_generation/resolution_error_handler.rb +++ b/lib/syskit/network_generation/resolution_error_handler.rb @@ -11,6 +11,14 @@ def initialize(errors) end end + # Reports the result of the network generation application. + SystemNetworkPlanApplyResult = + Struct.new :fulfilled, :instances, :errors, keyword_init: true do + def fulfilled? + fulfilled + end + end + # This is used to capture failures during the network generation process. Each # failure bundles the toplevel tasks that are related to the task that originates # the failure. It should be transformed into a ResolutionError for each related diff --git a/lib/syskit/runtime/apply_requirement_modifications.rb b/lib/syskit/runtime/apply_requirement_modifications.rb index 102d9eeea..1390e0c1e 100644 --- a/lib/syskit/runtime/apply_requirement_modifications.rb +++ b/lib/syskit/runtime/apply_requirement_modifications.rb @@ -103,7 +103,10 @@ def syskit_apply_async_resolution_results begin resolution_apply_result = syskit_current_resolution.apply - return unless resolution_apply_result.fulfilled + + unless resolution_apply_result.fulfilled? + return resolution_apply_result + end ensure syskit_current_resolution_keepalive.discard_transaction @syskit_current_resolution = nil @@ -115,12 +118,14 @@ def syskit_apply_async_resolution_results resolution_apply_result.errors.group_by(&:planning_task).each do |task, e| task.failed_event.emit e.flat_map(&:original_exception) end - nil + resolution_apply_result rescue ::Exception => e # rubocop:disable Lint/RescueException running_requirement_tasks.each do |t| t.failed_event.emit(e) end - e + NetworkGeneration::SystemNetworkPlanApplyResult.new( + fulfilled: false, errors: [e] + ) end end diff --git a/lib/syskit/test/instance_requirement_planning_handler.rb b/lib/syskit/test/instance_requirement_planning_handler.rb index ff3f9b93f..3cbba2517 100644 --- a/lib/syskit/test/instance_requirement_planning_handler.rb +++ b/lib/syskit/test/instance_requirement_planning_handler.rb @@ -56,17 +56,17 @@ def apply_requirements ) end - def finished? + def finished? # rubocop:disable Metrics/AbcSize Thread.pass if @plan.syskit_has_async_resolution? return unless @plan.syskit_finished_async_resolution? - error = @plan.syskit_apply_async_resolution_results - return true if error + resolution_results = @plan.syskit_apply_async_resolution_results + return true unless resolution_results.fulfilled? return unless @test.syskit_run_planner_stub? - root_tasks = @planning_tasks.map(&:planned_task) + root_tasks = resolution_results.instances.keys.map(&:planned_task) stub_network = StubNetwork.new(@test) # NOTE: this is a run-planner equivalent to syskit_stub_network diff --git a/testfile b/testfile new file mode 100644 index 000000000..e69de29bb