Class: ParallelTests::Turnip::Runner

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

Constant Summary collapse

NAME =
'Turnip'

Class Method Summary collapse

Class Method Details

.find_features_and_specs(tests, options = {}) ⇒ Array

Returns two array of feature and spec filename.

Parameters:

  • tests (Array)

    see tests_in_groups

  • options (Hash) (defaults to: {})

    see tests_in_groups

Returns:

  • (Array)

    two array of feature and spec filename



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/parallel_tests/turnip/runner.rb', line 40

def find_features_and_specs(tests, options = {})
  files = (tests || []).map do |file_or_folder|
    if File.directory?(file_or_folder)
      files = files_in_folder(file_or_folder, options)
      files.grep(/(\.feature|_spec\.rb)$/).grep(options[:pattern]||//)
    else
      file_or_folder
    end
  end.flatten.uniq

  files.partition { |file| file =~ /\.feature$/ }
end

.test_file_nameObject



10
11
12
# File 'lib/parallel_tests/turnip/runner.rb', line 10

def test_file_name
  'turnip'
end

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

Note:

Conditions of the grouping:

feature: number of turnip steps.
   spec: filesize.

Returns Test filenames that are grouped.

Parameters:

  • tests (Array)

    Selected files and folders at commandline.

  • num_groups (Integer)

    Number of processes to use.

  • options (Hash) (defaults to: {})

Returns:

  • (Array)

    Test filenames that are grouped.



26
27
28
29
30
31
32
# File 'lib/parallel_tests/turnip/runner.rb', line 26

def tests_in_groups(tests, num_groups, options={})
  features, specs = find_features_and_specs(tests, options)

  ftests = ::ParallelTests::Grouper.by_steps(features, num_groups, options)
  stests = ::ParallelTests::Grouper.in_even_groups_by_size(with_runtime_info(specs), num_groups, options)
  ftests.zip(stests).map { |t| t.flatten }
end