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 32 33 34 35 36 37 38 39 |
# File 'lib/hydra/runner.rb', line 18 def initialize(opts = {}) @io = opts.fetch(:io) { raise "No IO Object" } @verbose = opts.fetch(:verbose) { false } @worker_id = opts.fetch(:worker_id).to_i $stdout.sync = true trace 'Creating test database' ENV['HYDRA_WORKER_ID'] = (@worker_id == 0 ? '' : @worker_id).to_s ENV['TEST_ENV_NUMBER'] = (@worker_id == 0 ? '' : @worker_id + 1).to_s 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
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/hydra/runner.rb', line 42 def run_file(file) trace "Running file: #{file}" output = "" if file =~ /_spec.rb$/i output = run_rspec_file(file) elsif file =~ /.feature$/i output = run_cucumber_file(file) elsif file =~ /.js$/i or file =~ /.json$/i output = run_javascript_file(file) else output = run_test_unit_file(file) end output = "." if output == "" @io.write Results.new(:output => output, :file => file) return output end |
#stop ⇒ Object
Stop running
63 64 65 |
# File 'lib/hydra/runner.rb', line 63 def stop @running = false end |