class ParallelTests::Turnip::Runner

Constants

NAME

Public Class Methods

find_features_and_specs(tests, options = {}) click to toggle source

@param [Array] tests see tests_in_groups @param [Hash] options see tests_in_groups

@return [Array] two array of feature and spec filename

# 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_name() click to toggle source
# File lib/parallel_tests/turnip/runner.rb, line 10
def test_file_name
  'turnip'
end
tests_in_groups(tests, num_groups, options={}) click to toggle source

@note

Conditions of the grouping:
  feature: number of turnip steps.
     spec: filesize.

@param [Array] tests Selected files and folders at commandline. @param [Integer] num_groups Number of processes to use. @param [Hash] options

@return [Array] Test filenames that are grouped.

# 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