Module: TestR::Driver

Extended by:
Driver, Server
Included in:
Driver
Defined in:
lib/testr/driver.rb

Instance Method Summary (collapse)

Methods included from Server

quit

Instance Method Details

- (Object) loop



74
75
76
77
78
# File 'lib/testr/driver.rb', line 74

def loop
  reabsorb_overhead_files
  super
  quit_herald_and_master
end

- (Object) reabsorb_overhead_files



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
64
65
66
67
68
69
70
71
72
# File 'lib/testr/driver.rb', line 30

def reabsorb_overhead_files
  quit_herald_and_master if defined? @master

  @master = Client::Transceiver.new('testr-master') do |line|
    event, test_file = JSON.load(line)

    case event.to_sym
    when :test
      @running_test_files << test_file

    when :pass
      @passed_test_files << test_file unless @passed_test_files.include? test_file
      @running_test_files.delete test_file

    when :fail
      @failed_test_files << test_file unless @failed_test_files.include? test_file
      @running_test_files.delete test_file
    end

    @upstream.print line
  end

  @master.send [:load, Config.overhead_load_paths,
                Dir[*Config.overhead_file_globs]]

  @herald = Client::Receiver.new('testr-herald') do |line|
    changed_file = line.chomp

    # find and run the tests that correspond to the changed file
    Config.test_file_globbers.each do |source_regexp, test_globber|
      if source_regexp =~ changed_file
        run_test_files Dir[test_globber.call(changed_file).to_s]
      end
    end

    if Config.reabsorb_file_greps.any? {|r| r =~ changed_file }
      # spawn a new thread because reabsorb_overhead_files will kill this one
      Thread.new { reabsorb_overhead_files }.join
    end
  end

  rerun_running_test_files
end

- (Object) rerun_failed_test_files



26
27
28
# File 'lib/testr/driver.rb', line 26

def rerun_failed_test_files
  run_test_files @failed_test_files
end

- (Object) rerun_passed_test_files



22
23
24
# File 'lib/testr/driver.rb', line 22

def rerun_passed_test_files
  run_test_files @passed_test_files
end

- (Object) run_all_test_files



13
14
15
# File 'lib/testr/driver.rb', line 13

def run_all_test_files
  run_test_files Dir[*Config.all_test_file_globs]
end

- (Object) stop_running_test_files



17
18
19
20
# File 'lib/testr/driver.rb', line 17

def stop_running_test_files
  @master.send [:stop]
  @running_test_files.clear
end