提交 265f1349 编写于 作者: A Aaron Patterson

run railties tests in parallel, default to 2 cores

上级 a7e715e1
......@@ -33,6 +33,45 @@ def method_missing(name, *args)
end
module Isolation
require 'thread'
class ParallelEach
include Enumerable
# default to 2 cores
CORES = ENV['TEST_CORES'] || 2
def initialize list
@list = list
@queue = SizedQueue.new CORES
end
def grep pattern
self.class.new super
end
def each
threads = CORES.times.map {
Thread.new {
while job = @queue.pop
yield job
end
}
}
@list.each { |i| @queue << i }
CORES.times { @queue << nil }
threads.each(&:join)
end
end
def self.included klass
klass.extend(Module.new {
def test_methods
ParallelEach.new super
end
})
end
def self.forking_env?
!ENV["NO_FORK"] && ((RbConfig::CONFIG['host_os'] !~ /mswin|mingw/) && (RUBY_PLATFORM !~ /java/))
end
......
......@@ -23,8 +23,6 @@
module TestHelpers
module Paths
module_function
def app_template_path
File.join Dir.tmpdir, 'app_template'
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册