File: leftover_distributor.rb

package info (click to toggle)
ruby-knapsack 1.18.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 1,084 kB
  • sloc: ruby: 2,832; makefile: 4; sh: 3
file content (37 lines) | stat: -rw-r--r-- 818 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
module Knapsack
  module Distributors
    class LeftoverDistributor < BaseDistributor
      def report_tests
        @report_tests ||= report.keys
      end

      def leftover_tests
        @leftover_tests ||= all_tests - report_tests
      end

      private

      def post_assign_test_files_to_node
        node_index = 0
        leftover_tests.each do |test_file|
          node_tests[node_index] << test_file
          node_index += 1
          node_index %= ci_node_total
        end
      end

      def post_tests_for_node(node_index)
        test_files = node_tests[node_index]
        return unless test_files
        test_files
      end

      def default_node_tests
        @node_tests = []
        ci_node_total.times do |index|
          @node_tests[index] = []
        end
      end
    end
  end
end