Permalink
Browse files

'minitest/parallel_each' might not always be available

  • Loading branch information...
amatsuda committed Jan 29, 2013
1 parent 29000a7 commit eba172fb76ee46d9d801a5f3e56af7b777c9a13e
Showing with 4 additions and 1 deletion.
  1. +4 −1 activesupport/lib/active_support/testing/isolation.rb
@@ -1,5 +1,8 @@
require 'rbconfig'
require 'minitest/parallel_each'
begin
require 'minitest/parallel_each'
rescue LoadError
end
module ActiveSupport
module Testing

4 comments on commit eba172f

@zenspider

This comment has been minimized.

Show comment
Hide comment
@zenspider

zenspider Jan 29, 2013

Contributor

Isn't there a gem dependency on minitest? If so, it should always be available.

Contributor

zenspider replied Jan 29, 2013

Isn't there a gem dependency on minitest? If so, it should always be available.

@steveklabnik

This comment has been minimized.

Show comment
Hide comment
@amatsuda

This comment has been minimized.

Show comment
Hide comment
@amatsuda

amatsuda Jan 29, 2013

Member

Rails is depending on 'minitest', '~> 4.1' and ParallelEach was introduced after 4.1 release seattlerb/minitest@bdbf38d

Or can I bump up the dependency so we can remove the Rails version of ParallelEach here?

# Recent versions of MiniTest (such as the one shipped with Ruby 2.0) already define
# a ParallelEach class.
unless defined? ParallelEach
class ParallelEach
include Enumerable
# default to 2 cores
CORES = (ENV['TEST_CORES'] || 2).to_i
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
end

/cc @tenderlove

Member

amatsuda replied Jan 29, 2013

Rails is depending on 'minitest', '~> 4.1' and ParallelEach was introduced after 4.1 release seattlerb/minitest@bdbf38d

Or can I bump up the dependency so we can remove the Rails version of ParallelEach here?

# Recent versions of MiniTest (such as the one shipped with Ruby 2.0) already define
# a ParallelEach class.
unless defined? ParallelEach
class ParallelEach
include Enumerable
# default to 2 cores
CORES = (ENV['TEST_CORES'] || 2).to_i
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
end

/cc @tenderlove

@zenspider

This comment has been minimized.

Show comment
Hide comment
@zenspider

zenspider Jan 30, 2013

Contributor

Yeah. ~> 4.2 should be good.

Contributor

zenspider replied Jan 30, 2013

Yeah. ~> 4.2 should be good.

Please sign in to comment.