Module: Distributest

Defined in:
lib/distributest.rb,
lib/distributest/version.rb,
lib/distributest/formatter.rb,
lib/distributest/test_runner.rb

Defined Under Namespace

Modules: Formatter Classes: TestRunner

Constant Summary collapse

VERSION =
'0.0.6'

Class Method Summary collapse

Class Method Details

.start(runner_identifier, options = {}) ⇒ Object



12
13
14
15
# File 'lib/distributest.rb', line 12

def self.start(runner_identifier, options = {})
  ENV["DB_PREFIX"] = runner_identifier
  start_loop
end

.start_loopObject



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
# File 'lib/distributest.rb', line 17

def self.start_loop
  receive do |f|
    f.when([:file, String]) do |text|
      begin
        pass_results, fail_results, profile, total_time_for_file, captured_std_err_out = Distributest::TestRunner.new.run_rspec_file(text)
      rescue LoadError => e
        f.send!([:load_error, e.to_s])
      end
      pass_results = pass_results.to_s
      #Basically letting master know it ran a file even though it didn't have runnable specs
      if (pass_results.nil? || pass_results.length == 0) && (fail_results.nil? || fail_results.length == 0)
        f.send!([:pass_results, "."])
      else
        f.send!([:pass_results, pass_results]) unless pass_results.nil? or pass_results.length == 0
        f.send!([:fail_results, fail_results]) unless fail_results.nil? or fail_results.length == 0
        f.send!([:total_time_for_file, text, total_time_for_file])
        f.send!([:profile, text, profile])
        f.send!([:captured_std_err_out, captured_std_err_out]) unless captured_std_err_out == ""
      end
      f.send!(:ready_for_file)
      f.receive_loop
    end
    #stops the loop causing it to stop
    f.when(:stop) { f.send!([:port_shutdown, "normal"]) }

    f.when([:object, Any]) do |obj|
      puts "in ruby in Any with obj #{obj.inspect}"
      f.send!([:barf, "Barf in ruby with obj #{obj.inspect}"])
      f.receive_loop
    end
  end
end