Class: Hydra::Runner
- Inherits:
-
Object
- Object
- Hydra::Runner
- Includes:
- Messages::Runner
- Defined in:
- lib/hydra/runner.rb
Overview
Hydra class responsible for running test files.
The Runner is never run directly by a user. Runners are created by a Worker to run test files.
The general convention is to have one Runner for each logical processor of a machine.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Runner
constructor
Boot up a runner.
-
#run_file(file) ⇒ Object
Run a test file and report the results.
-
#stop ⇒ Object
Stop running.
Constructor Details
#initialize(opts = {}) ⇒ 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.
13 14 15 16 17 18 19 20 21 |
# File 'lib/hydra/runner.rb', line 13 def initialize(opts = {}) @io = opts.fetch(:io) { raise "No IO Object" } @verbose = opts.fetch(:verbose) { false } Test::Unit.run = true @io.write RequestFile.new end |
Instance Method Details
#run_file(file) ⇒ Object
Run a test file and report the results
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/hydra/runner.rb', line 24 def run_file(file) require file output = [] @result = Test::Unit::TestResult.new @result.add_listener(Test::Unit::TestResult::FAULT) do |value| output << value end klasses = Runner.find_classes_in_file(file) begin klasses.each{|klass| klass.suite.run(@result){|status, name| ;}} rescue => ex output << ex.to_s end output << '.' if output.empty? @io.write Results.new(:output => output.join("\n"), :file => file) end |
#stop ⇒ Object
Stop running
45 46 47 |
# File 'lib/hydra/runner.rb', line 45 def stop @running = false end |