Sha256: a72fbead50979e83381af9f2e1252a7dc460691c371532aeef5e31ea6d9ef141

Contents?: true

Size: 830 Bytes

Versions: 3

Compression:

Stored size: 830 Bytes

Contents

module Hydra #:nodoc:
  # Hydra class responsible for running test files
  class Runner
    # Boot up a runner. It takes an IO object (generally a pipe from its
    # parent) to send it messages on which files to execute.
    def initialize(io)
      @io = io
      @io.write Hydra::Messages::Runner::RequestFile.new
      process_messages
    end

    # The runner will continually read messages and handle them.
    def process_messages
      @running = true
      while @running
        message = @io.gets
        message.handle(self) if message
      end
    end

    # Run a test file and report the results
    def run_file(file)
      `ruby #{file}`
      @io.write Hydra::Messages::Runner::Results.new(:output => "Finished", :file => file)
    end

    # Stop running
    def stop
      @running = false
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hydra-0.4.1 lib/hydra/runner.rb
hydra-0.4.0 lib/hydra/runner.rb
hydra-0.3.0 lib/hydra/runner.rb