3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/parallel_tests/grouper.rb', line 3
def self.in_even_groups_by_size(items_with_sizes, num_groups, options = {})
groups = Array.new(num_groups) { {:items => [], :size => 0} }
(options[:single_process] || []).each do |pattern|
matched, items_with_sizes = items_with_sizes.partition { |item, size| item =~ pattern }
matched.each { |item, size| add_to_group(groups.first, item, size) }
end
groups_to_fill = (options[:isolate] ? groups[1..-1] : groups)
largest_first(items_with_sizes).each do |item, size|
smallest = smallest_group(groups_to_fill)
add_to_group(smallest, item, size)
end
groups.map!{|g| g[:items].sort }
end
|