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 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/hydra/runner.rb', line 34 def run_file(file) trace "Running file: #{file}" output = "" if file =~ /_spec.rb$/i output, stats = run_rspec_file(file) elsif file =~ /_testspec.rb$/i output, stats = run_test_spec_file(file) elsif file =~ /.feature$/i output, stats = run_cucumber_file(file) elsif file =~ /.js$/i or file =~ /.json$/i output, stats = run_javascript_file(file) else output, stats = run_test_unit_file(file) end output = "." if output == "" @io.write Results.new( :output => output, :file => file, :stats => stats ) return output end |
#stop ⇒ Object
Stop running
61 62 63 |
# File 'lib/hydra/runner.rb', line 61 def stop @running = false end |