aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authoryuuji.yaginuma <yuuji.yaginuma@gmail.com>2018-11-28 16:10:14 +0900
committeryuuji.yaginuma <yuuji.yaginuma@gmail.com>2018-11-28 16:10:14 +0900
commit4b5c4ca377a9b5c75d2c4b4d4f63f53866553b40 (patch)
tree919c7bfeca51a4f475fe1c354bbbab49d7bc971e /actionpack
parent8687a035d790865f2cc3a39163d77697aad92f2b (diff)
downloadrails-4b5c4ca377a9b5c75d2c4b4d4f63f53866553b40.tar.gz
rails-4b5c4ca377a9b5c75d2c4b4d4f63f53866553b40.tar.bz2
rails-4b5c4ca377a9b5c75d2c4b4d4f63f53866553b40.zip
Use `Testing::Parallelization` in Action Packs's test
Parallel execution of `ForkingExecutor` is the same approach as `Testing::Parallelization`. So do not need to have own code inside Action Pack. Let's use an already existing feature.
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/test/abstract_unit.rb78
1 files changed, 1 insertions, 77 deletions
diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb
index 65dd28b3d7..f23151e518 100644
--- a/actionpack/test/abstract_unit.rb
+++ b/actionpack/test/abstract_unit.rb
@@ -13,13 +13,6 @@ silence_warnings do
Encoding.default_external = Encoding::UTF_8
end
-require "drb"
-begin
- require "drb/unix"
-rescue LoadError
- puts "'drb/unix' is not available"
-end
-
if ENV["TRAVIS"]
PROCESS_COUNT = 0
else
@@ -80,7 +73,7 @@ end
module ActiveSupport
class TestCase
if RUBY_ENGINE == "ruby" && PROCESS_COUNT > 0
- parallelize_me!
+ parallelize(workers: PROCESS_COUNT)
end
end
end
@@ -359,75 +352,6 @@ class ImagesController < ResourcesController; end
require "active_support/testing/method_call_assertions"
-class ForkingExecutor
- class Server
- include DRb::DRbUndumped
-
- def initialize
- @queue = Queue.new
- end
-
- def record(reporter, result)
- reporter.record result
- end
-
- def <<(o)
- o[2] = DRbObject.new(o[2]) if o
- @queue << o
- end
- def pop; @queue.pop; end
- end
-
- def initialize(size)
- @size = size
- @queue = Server.new
- @pool = nil
- @url = DRb.start_service("drbunix:", @queue).uri
- end
-
- def <<(work); @queue << work; end
-
- def shutdown
- pool = @size.times.map {
- fork {
- DRb.stop_service
- queue = DRbObject.new_with_uri @url
- while job = queue.pop
- klass = job[0]
- method = job[1]
- reporter = job[2]
- result = Minitest.run_one_method klass, method
- if result.error?
- translate_exceptions result
- end
- queue.record reporter, result
- end
- }
- }
- @size.times { @queue << nil }
- pool.each { |pid| Process.waitpid pid }
- end
-
- private
- def translate_exceptions(result)
- result.failures.map! { |e|
- begin
- Marshal.dump e
- e
- rescue TypeError
- ex = Exception.new e.message
- ex.set_backtrace e.backtrace
- Minitest::UnexpectedError.new ex
- end
- }
- end
-end
-
-if RUBY_ENGINE == "ruby" && PROCESS_COUNT > 0
- # Use N processes (N defaults to 4)
- Minitest.parallel_executor = ForkingExecutor.new(PROCESS_COUNT)
-end
-
class ActiveSupport::TestCase
include ActiveSupport::Testing::MethodCallAssertions