Sha256: 9902421135b110e104cb60642477e3bea64b0bb5fcaf329b652ee86426ca111e

Contents?: true

Size: 1.59 KB

Versions: 40

Compression:

Stored size: 1.59 KB

Contents

module OrigenTesters::ATP
  module Validators
    class Jobs < Validator
      def setup
        @conflicting = []
        @negative = []
      end

      def on_completion
        failed = false
        unless @conflicting.empty?
          error 'if_job and unless_job conditions cannot both be applied to the same tests'
          error "The following conflicts were found in flow #{flow.name}:"
          @conflicting.each do |a, b|
            a_condition = a.to_a[1] ? 'if_job:    ' : 'unless_job:'
            b_condition = b.to_a[1] ? 'if_job:    ' : 'unless_job:'
            error "  #{a_condition} #{a.source}"
            error "  #{b_condition} #{b.source}"
            error ''
          end
          failed = true
        end

        unless @negative.empty?
          error 'Job names should not be negated, use unless_job if you want to specify !JOB'
          error "The following negative job names were found in flow #{flow.name}:"
          @negative.each do |node|
            error "  #{node.to_a[0]} #{node.source}"
          end
          failed = true
        end

        failed
      end

      def on_if_job(node)
        jobs, *nodes = *node
        jobs = [jobs].flatten
        state = node.type == :if_job
        if jobs.any? { |j| j.to_s =~ /^(!|~)/ }
          @negative << node
        end
        @stack ||= []
        if !@stack.empty? && @stack.last[1] != state
          @conflicting << [@stack.last[0], node]
        else
          @stack << [node, state]
          process_all(node)
          @stack.pop
        end
      end
      alias_method :on_unless_job, :on_if_job
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

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