Class: Spec::Distributed::SlaveRunner
- Inherits:
-
Runner::BehaviourRunner
- Object
- Runner::BehaviourRunner
- Spec::Distributed::SlaveRunner
- Defined in:
- lib/spec/distributed/slave_runner.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(options, args = nil) ⇒ SlaveRunner
constructor
A new instance of SlaveRunner.
-
#prepare_run(master_paths, master_svn_rev) ⇒ Object
This is called by the master over DRb.
- #process_args(args) ⇒ Object
-
#report_dump ⇒ Object
This is called by the master over DRb.
- #run(paths, exit_when_done) ⇒ Object
-
#run_behaviour_at(behaviour_index, dry_run, reverse, timeout) ⇒ Object
This is called by the master over DRb.
- #top_svn_dir ⇒ Object
- #update_wc(master_svn_rev) ⇒ Object
Constructor Details
#initialize(options, args = nil) ⇒ SlaveRunner
Returns a new instance of SlaveRunner.
4 5 6 7 |
# File 'lib/spec/distributed/slave_runner.rb', line 4 def initialize(, args=nil) super() process_args(args) end |
Instance Method Details
#prepare_run(master_paths, master_svn_rev) ⇒ Object
This is called by the master over DRb.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/spec/distributed/slave_runner.rb', line 22 def prepare_run(master_paths, master_svn_rev) begin update_wc(master_svn_rev) prepare!(master_paths) rescue => e STDERR.puts e. STDERR.puts e.backtrace.join("\n") exit(1) end end |
#process_args(args) ⇒ Object
9 10 11 12 |
# File 'lib/spec/distributed/slave_runner.rb', line 9 def process_args(args) @url = args raise "You must pass the DRb URL: --runner #{self.class}:druby://host1:port1" if @url.nil? end |
#report_dump ⇒ Object
This is called by the master over DRb.
53 54 55 56 |
# File 'lib/spec/distributed/slave_runner.rb', line 53 def report_dump super puts "=" * 70 end |
#run(paths, exit_when_done) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/spec/distributed/slave_runner.rb', line 14 def run(paths, exit_when_done) @started = true puts "Whip me on #{slave_watermark}" DRb.start_service(@url, self) DRb.thread.join end |
#run_behaviour_at(behaviour_index, dry_run, reverse, timeout) ⇒ Object
This is called by the master over DRb.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/spec/distributed/slave_runner.rb', line 34 def run_behaviour_at(behaviour_index, dry_run, reverse, timeout) begin behaviour = @behaviours[behaviour_index] # We'll report locally, but also record what happened so we can send # that back to the master recorder = Recorder.new(slave_watermark) reporter = Dispatcher.new(recorder, @options.reporter) behaviour.run(reporter, dry_run, reverse, timeout) recorder rescue => e STDERR.puts e. STDERR.puts e.backtrace.join("\n") exit(1) end end |
#top_svn_dir ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/spec/distributed/slave_runner.rb', line 68 def top_svn_dir dir = '.' loop do up = File.join(dir, '..') if File.directory?(File.join(up, '.svn')) dir = up else break end end dir end |
#update_wc(master_svn_rev) ⇒ Object
58 59 60 61 62 63 64 65 66 |
# File 'lib/spec/distributed/slave_runner.rb', line 58 def update_wc(master_svn_rev) Dir.chdir(top_svn_dir) do local_rev = `svn info`.match(/^Revision: (\d+)$/n)[1] rescue nil raise "This is not a svn working copy, but the master is (r#{master_svn_rev})" if master_svn_rev && local_rev.nil? if(local_rev.to_i != master_svn_rev.to_i) system("svn up -r#{master_svn_rev}") end end end |