Skip to content
Browse files

Add ability to pass :vnc => SomeClass to override the default VncTool…

…s::Server.

This makes the displays configurable, e.g. you could do

  class MyVncDisplay < VncTools::Server
    def launch_arguments
      %w[-geometry 1280x1024]
    end
  end

  Runner.create(feature,s :vnc => MyVncDisplay)
  • Loading branch information...
1 parent 0780ee2 commit 1685cd13a8e46c7eeb45d481864f51f159fb45f3 @jarib committed
Showing with 33 additions and 17 deletions.
  1. +23 −17 lib/cukeforker/runner.rb
  2. +10 −0 spec/cukeforker/runner_spec.rb
View
40 lib/cukeforker/runner.rb
@@ -6,17 +6,18 @@ module CukeForker
# where 'features' is an Array of file:line
# and 'opts' is a Hash of options:
#
- # :max => Fixnum number of workers (default: 2)
- # :vnc => true/false children are launched with DISPLAY set from a VNC server pool,
- # where the size of the pool is equal to :max
- # :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,
- # these 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
+ # :max => Fixnum number of workers (default: 2)
+ # :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
#
class Runner
@@ -49,8 +50,13 @@ def self.create(features, opts = {})
listeners << LoggingListener.new
end
- if opts[:vnc]
- vnc_pool = VncTools::ServerPool.new(max)
+ 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]
@@ -71,10 +77,10 @@ def self.create(features, opts = {})
runner = Runner.new queue
- listeners.each { |listener|
- queue.add_observer listener
- runner.add_observer listener
- vnc_pool.add_observer listener if opts[:vnc]
+ listeners.each { |l|
+ queue.add_observer l
+ runner.add_observer l
+ vnc_pool.add_observer l if opts[:vnc]
}
runner
View
10 spec/cukeforker/runner_spec.rb
@@ -44,6 +44,16 @@ module CukeForker
Runner.create([], :max => 2, :vnc => true)
end
+ it "sets up the VNC pool with a custom server class" do
+ server_class = Class.new
+
+ mock_pool = mock(VncTools::ServerPool, :add_observer => nil)
+ VncTools::ServerPool.should_receive(:new).with(2, server_class).and_return mock_pool
+ VncListener.should_receive(:new).with(mock_pool).and_return mock(:update => nil)
+
+ Runner.create([], :max => 2, :vnc => server_class)
+ end
+
it "sets up VNC recording if :record => true" do
mock_pool = mock(VncTools::ServerPool, :add_observer => nil)
VncTools::ServerPool.should_receive(:new).with(2).and_return mock_pool

0 comments on commit 1685cd1

Please sign in to comment.
Something went wrong with that request. Please try again.