Class: CukeForker::Runner
- Inherits:
-
Object
- Object
- CukeForker::Runner
- Includes:
- Observable
- Defined in:
- lib/cukeforker/runner.rb
Overview
Runner.run(features, opts)
where ‘features’ is an Array of file:line and ‘opts’ is a Hash of options:
:max => Fixnum number of workers (default: 2, pass 0 for unlimited)
:vnc => true/false,Class children are launched with DISPLAY set from a VNC server pool,
where the size of the pool is equal to :max. If passed a Class instance,
this will be passed as the second argument to VncTools::ServerPool.
:record => true/false,Hash whether to record a video of failed tests (requires ffmpeg)
this will be ignored if if :vnc is not true. If passed a Hash,
this will be passed as options to RecordingVncListener
:notify => object (or array of objects) implementing the AbstractListener API
:out => path directory to dump output to (default: current working dir)
:log => true/false wether or not to log to stdout (default: true)
:format => Symbol format passed to `cucumber --format` (default: html)
:extra_args => Array extra arguments passed to cucumber
Constant Summary collapse
- DEFAULT_OPTIONS =
{ :max => 2, :vnc => false, :record => false, :notify => nil, :out => Dir.pwd, :log => true, :format => :html }
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(queue) ⇒ Runner
constructor
A new instance of Runner.
- #run ⇒ Object
Constructor Details
#initialize(queue) ⇒ Runner
Returns a new instance of Runner.
89 90 91 |
# File 'lib/cukeforker/runner.rb', line 89 def initialize(queue) @queue = queue end |
Class Method Details
.create(features, opts = {}) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/cukeforker/runner.rb', line 40 def self.create(features, opts = {}) opts = DEFAULT_OPTIONS.dup.merge(opts) max = opts[:max] format = opts[:format] out = File.join opts[:out] listeners = Array(opts[:notify]) extra_args = Array(opts[:extra_args]) if opts[:log] listeners << LoggingListener.new end if vnc = opts[:vnc] if vnc.kind_of?(Class) vnc_pool = VncTools::ServerPool.new(max, vnc) else vnc_pool = VncTools::ServerPool.new(max) end listener = VncListener.new(vnc_pool) if record = opts[:record] if record.kind_of?(Hash) listeners << RecordingVncListener.new(listener, record) else listeners << RecordingVncListener.new(listener) end else listeners << listener end end queue = WorkerQueue.new max features.each do |feature| queue.add Worker.new(feature, format, out, extra_args) end runner = Runner.new queue listeners.each { |l| queue.add_observer l runner.add_observer l vnc_pool.add_observer l if opts[:vnc] } runner end |
.run(features, opts = {}) ⇒ Object
36 37 38 |
# File 'lib/cukeforker/runner.rb', line 36 def self.run(features, opts = {}) create(features, opts).run end |
Instance Method Details
#run ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/cukeforker/runner.rb', line 93 def run start process stop rescue Interrupt fire :on_run_interrupted stop rescue StandardError fire :on_run_interrupted stop raise end |