class ParallelTests::Test::Runner
def sort_by_runtime(tests, runtimes, options={})
def sort_by_runtime(tests, runtimes, options={}) allowed_missing = options[:allowed_missing] || 1.0 allowed_missing = tests.size * allowed_missing # set know runtime for each test tests.sort! tests.map! do |test| allowed_missing -= 1 unless time = runtimes[test] raise "Too little runtime info" if allowed_missing < 0 [test, time] end if options[:verbose] puts "Runtime found for #{tests.count(&:last)} of #{tests.size} tests" end # fill gaps with average runtime known, unknown = tests.partition(&:last) average = (known.any? ? known.map!(&:last).inject(:+) / known.size : 1) unknown.each { |set| set[1] = average } end