Class: KnapsackPro::TestFileFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/knapsack_pro/test_file_finder.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(test_file_pattern, test_file_list_enabled) ⇒ TestFileFinder

Returns a new instance of TestFileFinder.



27
28
29
30
# File 'lib/knapsack_pro/test_file_finder.rb', line 27

def initialize(test_file_pattern, test_file_list_enabled)
  @test_file_pattern = test_file_pattern
  @test_file_list_enabled = test_file_list_enabled
end

Class Method Details

.call(test_file_pattern, test_file_list_enabled: true) ⇒ Object



5
6
7
# File 'lib/knapsack_pro/test_file_finder.rb', line 5

def self.call(test_file_pattern, test_file_list_enabled: true)
  new(test_file_pattern, test_file_list_enabled).call
end

.select_test_files_that_can_be_run(adapter_class, candidate_test_files) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/knapsack_pro/test_file_finder.rb', line 18

def self.select_test_files_that_can_be_run(adapter_class, candidate_test_files)
  test_file_pattern = KnapsackPro::TestFilePattern.call(adapter_class)
  scheduled_test_files = call(test_file_pattern)
  scheduled_paths = KnapsackPro::TestFilePresenter.paths(scheduled_test_files)
  candidate_paths = KnapsackPro::TestFilePresenter.paths(candidate_test_files)
  paths = scheduled_paths & candidate_paths
  candidate_test_files.filter { |test_file| paths.include? test_file.fetch('path') }
end

.slow_test_files_by_pattern(adapter_class) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/knapsack_pro/test_file_finder.rb', line 9

def self.slow_test_files_by_pattern(adapter_class)
  raise 'KNAPSACK_PRO_SLOW_TEST_FILE_PATTERN is not defined' unless KnapsackPro::Config::Env.slow_test_file_pattern

  test_file_pattern = KnapsackPro::TestFilePattern.call(adapter_class)
  scheduled_test_files = call(test_file_pattern)
  slow_test_files = call(KnapsackPro::Config::Env.slow_test_file_pattern, test_file_list_enabled: false)
  scheduled_test_files & slow_test_files
end

Instance Method Details

#callObject



32
33
34
35
36
# File 'lib/knapsack_pro/test_file_finder.rb', line 32

def call
  file_paths.map do |file_path|
    { 'path' => TestFileCleaner.clean(file_path) }
  end
end