Class: JCukeForker::Runner
- Inherits:
-
Object
- Object
- JCukeForker::Runner
- Includes:
- Observable
- Defined in:
- lib/jcukeforker/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,Array 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 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
:delay => Numeric seconds to sleep between each worker is started (default: 0)
:port => String port that the event server runs on
(default: 6333)
Constant Summary collapse
- DEFAULT_OPTIONS =
{ :max => 2, :vnc => false, :record => false, :notify => nil, :out => Dir.pwd, :log => true, :format => :html, :delay => 0, :port => '6333' }
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(status_server, processes, worker_dir, vnc_pool, delay, task_manager) ⇒ Runner
constructor
A new instance of Runner.
- #run ⇒ Object
Constructor Details
#initialize(status_server, processes, worker_dir, vnc_pool, delay, task_manager) ⇒ Runner
Returns a new instance of Runner.
91 92 93 94 95 96 97 98 |
# File 'lib/jcukeforker/runner.rb', line 91 def initialize(status_server, processes, worker_dir, vnc_pool, delay, task_manager) @status_server = status_server @processes = processes @worker_dir = worker_dir @vnc_pool = vnc_pool @delay = delay @task_manager = task_manager end |
Class Method Details
.create(features, opts = {}) ⇒ Object
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 88 89 |
# File 'lib/jcukeforker/runner.rb', line 44 def self.create(features, opts = {}) opts = DEFAULT_OPTIONS.dup.merge(opts) max = opts[:max] raise ':max must be >= 1' if max < 1 format = opts[:format] out = File.join opts[:out] listeners = Array(opts[:notify]) extra_args = Array(opts[:extra_args]) delay = opts[:delay] port = opts[:port] if opts[:log] listeners << LoggingListener.new end task_opts = {format: format,out: out,extra_args: extra_args} task_manager = TaskManager.new features, task_opts listeners << task_manager status_server = StatusServer.new port worker_dir = "/tmp/jcukeforker-#{SecureRandom.hex 4}" FileUtils.mkdir_p worker_dir vnc_pool = nil if vnc = opts[:vnc] if vnc.kind_of?(Array) vnc_pool = VncTools::ServerPool.new(max, ConfigurableVncServer.create_class(vnc)) elsif vnc.kind_of?(Class) vnc_pool = VncTools::ServerPool.new(max, vnc) else vnc_pool = VncTools::ServerPool.new(max) end end processes = create_processes(max, status_server.port, worker_dir, vnc_pool, opts[:record]) runner = Runner.new status_server, processes, worker_dir, vnc_pool, delay, task_manager listeners.each { |l| status_server.add_observer l runner.add_observer l } runner end |
.run(features, opts = {}) ⇒ Object
40 41 42 |
# File 'lib/jcukeforker/runner.rb', line 40 def self.run(features, opts = {}) create(features, opts).run end |
Instance Method Details
#run ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/jcukeforker/runner.rb', line 100 def run start process stop rescue Interrupt fire :on_run_interrupted stop rescue StandardError => e STDERR.puts e.backtrace fire :on_run_interrupted stop raise end |