Class: Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, tours, number, runner_id, test_list) ⇒ Runner

Returns a new instance of Runner.



10
11
12
13
14
# File 'lib/runner.rb', line 10

def initialize(host, tours, number, runner_id, test_list)
  @host, @tours, @number, @runner_id, @test_list = host, tours, number, runner_id, test_list
  @runner_type = self.send(:class).to_s
  log("Ready to run #{@runner_type}")
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



8
9
10
# File 'lib/runner.rb', line 8

def host
  @host
end

#numberObject (readonly)

Returns the value of attribute number.



8
9
10
# File 'lib/runner.rb', line 8

def number
  @number
end

#runner_idObject (readonly)

Returns the value of attribute runner_id.



8
9
10
# File 'lib/runner.rb', line 8

def runner_id
  @runner_id
end

#runner_typeObject (readonly)

Returns the value of attribute runner_type.



8
9
10
# File 'lib/runner.rb', line 8

def runner_type
  @runner_type
end

#toursObject (readonly)

Returns the value of attribute tours.



8
9
10
# File 'lib/runner.rb', line 8

def tours
  @tours
end

Instance Method Details

#run_toursObject

Dispatches to subclass run method



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/runner.rb', line 17

def run_tours 
  log "Filtering on tests #{@test_list.join(', ')}" unless @test_list.to_a.empty?
  tours,tests,passes,fails,errors = 0,0,0,0,0
  1.upto(number) do |num|
    log("Starting #{@runner_type} run #{num}/#{number}")
    @tours.each do |tour_name|
      
      log("Starting run #{number} of Tour #{tour_name}")
      tours += 1
      tour = Tour.make_tour(tour_name,@host,@tours,@number,@runner_id)
      tour.before_tour
      
      tour.tests.each do |test|

        next if test_limited_to(test) #  test_list && !test_list.empty? && !test_list.include?(test.to_s) 

        begin
          tests += 1
          tour.run_test test
          passes += 1
        rescue TourBusException, WebratError => e
          log("********** FAILURE IN RUN! **********")
          log e.message
          e.backtrace.each do |trace|
            log trace
          end
          fails += 1
        rescue Exception => e
          log("*************************************")
          log("*********** ERROR IN RUN! ***********")
          log("*************************************")
          log e.message
          e.backtrace.each do |trace|
            log trace
          end
          errors += 1
        end 
        log("Finished run #{number} of Tour #{tour_name}")
      end
      
      tour.after_tour
    end
    log("Finished #{@runner_type} run #{num}/#{number}")
  end
  log("Finished all #{@runner_type} tours.")
  [tours,tests,passes,fails,errors]
end