Class: KnapsackPro::SlowTestFileDeterminer

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

Constant Summary collapse

TIME_THRESHOLD_PER_CI_NODE =

70%

0.7

Class Method Summary collapse

Class Method Details

.call(test_files) ⇒ Object

test_files: { ‘path’ => ‘a_spec.rb’, ‘time_execution’ => 0.0 }



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/knapsack_pro/slow_test_file_determiner.rb', line 8

def self.call(test_files)
  total_execution_time = test_files.sum { |test_file| test_file.fetch('time_execution') }
  time_threshold = (total_execution_time / KnapsackPro::Config::Env.ci_node_total) * TIME_THRESHOLD_PER_CI_NODE

  test_files.select do |test_file|
    execution_time = test_file.fetch('time_execution')
    next false if execution_time.zero?
    next true if execution_time >= time_threshold
    next false unless KnapsackPro::Config::Env.slow_test_file_threshold?

    execution_time >= KnapsackPro::Config::Env.slow_test_file_threshold
  end
end