Sha256: 7f3af8aa8b24a89c8aaba6edf817f26caabd7ca368470c0ea7cfe5d1c08e67f9

Contents?: true

Size: 1004 Bytes

Versions: 5

Compression:

Stored size: 1004 Bytes

Contents

require 'ast'
module ATP
  class Validator < Processor
    attr_reader :flow

    def self.testing=(value)
      @testing = value
    end

    def self.testing
      @testing
    end

    def initialize(flow)
      @flow = flow
    end

    def process(node)
      if @top_level_called
        super
      else
        @top_level_called = true
        setup
        super(node)
        unless @testing
          exit 1 if on_completion
        end
      end
    end

    # For test purposes, returns true if validation failed rather
    # than exiting the process
    def test_process(node)
      @testing = true
      process(node)
      on_completion
    end

    def setup
    end

    def error(message)
      # This is a hack to make the specs pass, for some reason RSpec
      # seems to be swallowing the Origen log output after the first
      # test that generates an error
      if Validator.testing
        puts message
      else
        Origen.log.error(message)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
atp-1.1.3 lib/atp/validator.rb
atp-1.1.2 lib/atp/validator.rb
atp-1.1.1 lib/atp/validator.rb
atp-1.1.0 lib/atp/validator.rb
atp-1.0.0 lib/atp/validator.rb