Sha256: 0449d30cacca346ad4e68b0f2ed12a35d73de8b2b5a9badc43dadd10dde13f92

Contents?: true

Size: 1.33 KB

Versions: 40

Compression:

Stored size: 1.33 KB

Contents

module OrigenTesters::ATP
  module Processors
    # This removes on_pass/fail operations from groups and applies them to all
    # contained tests
    class ApplyPostGroupActions < Processor
      def run(node)
        @on_pass = []
        @on_fail = []
        process(node)
      end

      def on_group(node)
        on_pass = node.find(:on_pass)
        on_fail = node.find(:on_fail)
        @on_pass << on_pass
        @on_fail << on_fail
        node = node.remove(on_pass) if on_pass
        node = node.remove(on_fail) if on_fail
        node = node.updated(nil, process_all(node.children))
        @on_fail.pop
        @on_pass.pop
        node
      end

      def on_test(node)
        node = node.ensure_node_present(:on_pass) if @on_pass.any? { |n| n }
        node = node.ensure_node_present(:on_fail) if @on_fail.any? { |n| n }
        node.updated(nil, process_all(node.children))
      end

      def on_on_pass(node)
        @on_pass.each do |on_pass|
          if on_pass
            node = node.updated(nil, node.children + process_all(on_pass.children))
          end
        end
        node
      end

      def on_on_fail(node)
        @on_fail.each do |on_fail|
          if on_fail
            node = node.updated(nil, node.children + process_all(on_fail.children))
          end
        end
        node
      end
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
origen_testers-0.52.8 lib/origen_testers/atp/processors/apply_post_group_actions.rb
origen_testers-0.52.7 lib/origen_testers/atp/processors/apply_post_group_actions.rb
origen_testers-0.52.6 lib/origen_testers/atp/processors/apply_post_group_actions.rb
origen_testers-0.52.5 lib/origen_testers/atp/processors/apply_post_group_actions.rb
origen_testers-0.52.4 lib/origen_testers/atp/processors/apply_post_group_actions.rb
origen_testers-0.52.3 lib/origen_testers/atp/processors/apply_post_group_actions.rb
origen_testers-0.52.1 lib/origen_testers/atp/processors/apply_post_group_actions.rb
origen_testers-0.52.0 lib/origen_testers/atp/processors/apply_post_group_actions.rb
origen_testers-0.51.5 lib/origen_testers/atp/processors/apply_post_group_actions.rb
origen_testers-0.51.4 lib/origen_testers/atp/processors/apply_post_group_actions.rb
origen_testers-0.51.3 lib/origen_testers/atp/processors/apply_post_group_actions.rb
origen_testers-0.51.2 lib/origen_testers/atp/processors/apply_post_group_actions.rb
origen_testers-0.51.1 lib/origen_testers/atp/processors/apply_post_group_actions.rb
origen_testers-0.51.0 lib/origen_testers/atp/processors/apply_post_group_actions.rb
origen_testers-0.50.0 lib/origen_testers/atp/processors/apply_post_group_actions.rb
origen_testers-0.49.4 lib/origen_testers/atp/processors/apply_post_group_actions.rb
origen_testers-0.49.3 lib/origen_testers/atp/processors/apply_post_group_actions.rb
origen_testers-0.49.2 lib/origen_testers/atp/processors/apply_post_group_actions.rb
origen_testers-0.49.1 lib/origen_testers/atp/processors/apply_post_group_actions.rb
origen_testers-0.49.0 lib/origen_testers/atp/processors/apply_post_group_actions.rb