Class: Specjour::Worker

Inherits:
Object
  • Object
show all
Includes:
Protocol, SocketHelper
Defined in:
lib/specjour/worker.rb

Constant Summary

Constants included from Protocol

Protocol::TERMINATOR, Protocol::TERMINATOR_REGEXP

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SocketHelper

#current_uri, #hostname, #ip_from_hostname, #local_ip, #new_uri

Methods included from Protocol

#dump_object, #load_object

Constructor Details

#initialize(options = {}) ⇒ Worker

Returns a new instance of Worker.



9
10
11
12
13
14
15
16
# File 'lib/specjour/worker.rb', line 9

def initialize(options = {})
  ARGV.replace []
  $stdout = StringIO.new if options[:quiet]
  @number = options[:number].to_i
  self.printer_uri = options[:printer_uri]
  set_env_variables
  Specjour.load_custom_hooks
end

Instance Attribute Details

#numberObject (readonly)

Returns the value of attribute number.



7
8
9
# File 'lib/specjour/worker.rb', line 7

def number
  @number
end

#printer_uriObject

Returns the value of attribute printer_uri.



6
7
8
# File 'lib/specjour/worker.rb', line 6

def printer_uri
  @printer_uri
end

Instance Method Details

#prepareObject



22
23
24
# File 'lib/specjour/worker.rb', line 22

def prepare
  Configuration.prepare.call
end

#run_testsObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/specjour/worker.rb', line 26

def run_tests
  Configuration.after_fork.call
  run_times = Hash.new(0)

  while test = connection.next_test
    print_status(test)
    time = Benchmark.realtime { run_test test }
    profile(test, time)
    run_times[test_type(test)] += time
    connection.send_message(:done)
  end

  send_run_times(run_times)
ensure
  connection.disconnect
end