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)
Constant Summary collapse
- DEFAULT_OPTIONS =
{ :max => 2, :vnc => false, :record => false, :notify => nil, :out => Dir.pwd, :log => true, :format => :html, :delay => 0, }
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(status_server, processes, vnc_pool, delay, task_manager) ⇒ Runner
constructor
A new instance of Runner.
- #run ⇒ Object
Constructor Details
#initialize(status_server, processes, vnc_pool, delay, task_manager) ⇒ Runner
Returns a new instance of Runner.
95 96 97 98 99 100 101 |
# File 'lib/jcukeforker/runner.rb', line 95 def initialize(status_server, processes, vnc_pool, delay, task_manager) @status_server = status_server @processes = processes @vnc_pool = vnc_pool @delay = delay @task_manager = task_manager end |
Class Method Details
.create(features, opts = {}) ⇒ Object
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 88 89 90 91 92 93 |
# File 'lib/jcukeforker/runner.rb', line 41 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.(File.join(opts[:out])) listeners = Array(opts[:notify]) extra_args = Array(opts[:extra_args]) delay = opts[:delay] puts "The port option is deprecated in jcukeforker > 0.2.10" if opts[:port] if opts[:log] listeners << LoggingListener.new end FileUtils.mkdir_p out io_in = File.join out, 'in' io_out = File.join out, 'out' # truncate File.open(io_in, 'w') {} File.open(io_out, 'w') {} task_opts = {format: format,out: out,extra_args: extra_args} io_out_file = File.open(io_out, 'a') io_out_file.sync = true task_manager = TaskManager.new features, io_out_file, task_opts listeners << task_manager status_server = StatusServer.new io_in 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, io_in, io_out, vnc_pool, opts[:record]) runner = Runner.new status_server, processes, vnc_pool, delay, task_manager listeners.each { |l| status_server.add_observer l runner.add_observer l } runner end |
.run(features, opts = {}) ⇒ Object
37 38 39 |
# File 'lib/jcukeforker/runner.rb', line 37 def self.run(features, opts = {}) create(features, opts).run end |
Instance Method Details
#run ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/jcukeforker/runner.rb', line 103 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 |