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.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/hydra/runner.rb', line 18 def initialize(opts = {}) @io = opts.fetch(:io) { raise "No IO Object" } @verbose = opts.fetch(:verbose) { false } $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 |
# File 'lib/hydra/runner.rb', line 34 def run_file(file) trace "Running file: #{file}" output = "" if file =~ /.rb$/ output = run_ruby_file(file) elsif file =~ /.feature$/ output = run_cucumber_file(file) end output = "." if output == "" @io.write Results.new(:output => output, :file => file) return output end |
#stop ⇒ Object
Stop running
51 52 53 |
# File 'lib/hydra/runner.rb', line 51 def stop @running = false end |