Class: ParallelTests::Saucerspec::Runner

Inherits:
RSpec::Runner
  • Object
show all
Defined in:
lib/parallel_tests/saucerspec/runner.rb

Class Method Summary collapse

Class Method Details

.run_tests(test_files, process_number, num_processes, options) ⇒ Object


8
9
10
11
12
13
14
15
16
17
# File 'lib/parallel_tests/saucerspec/runner.rb', line 8

def self.run_tests(test_files, process_number, num_processes, options)
  our_options = options.dup
  exe = executable # expensive, so we cache
  version = (exe =~ /\brspec\b/ ? 2 : 1)
  cmd = [exe, our_options[:test_options], (rspec_2_color if version == 2), spec_opts, *test_files].compact.join(" ")
  env = Sauce::TestBroker.next_environment(test_files)
  env << " #{rspec_1_color}" if version == 1
  our_options.merge!(:env => env)
  execute_command(cmd, process_number, num_processes, our_options)
end

.tests_in_groups(tests, num_groups, options = {}) ⇒ Object


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/parallel_tests/saucerspec/runner.rb', line 20

def self.tests_in_groups(tests, num_groups, options={})
  all_tests = super.flatten * Sauce::TestBroker.test_platforms(:rspec).length
  base_group_size = all_tests.length / num_groups
  num_full_groups = all_tests.length - (base_group_size * num_groups)

  curpos = 0
  groups = []
  num_groups.times do |i|
    group_size = base_group_size
    if i < num_full_groups
      group_size += 1
    end
    groups << all_tests.slice(curpos, group_size)
    curpos += group_size
  end

  groups
end