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.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/hydra/runner.rb', line 16 def initialize(opts = {}) @io = opts.fetch(:io) { raise "No IO Object" } @verbose = opts.fetch(:verbose) { false } Test::Unit.run = true $stdout.sync = true trace 'Booted. Sending Request for file' @io.write RequestFile.new begin rescue => ex trace ex.to_s raise ex end end |
Instance Method Details
#run_file(file) ⇒ Object
Run a test file and report the results
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/hydra/runner.rb', line 34 def run_file(file) trace "Running 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
56 57 58 |
# File 'lib/hydra/runner.rb', line 56 def stop @running = false end |