aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/testing/parallelization.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/testing/parallelization.rb')
-rw-r--r--activesupport/lib/active_support/testing/parallelization.rb34
1 files changed, 32 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/testing/parallelization.rb b/activesupport/lib/active_support/testing/parallelization.rb
index 63440069b1..96518a4a58 100644
--- a/activesupport/lib/active_support/testing/parallelization.rb
+++ b/activesupport/lib/active_support/testing/parallelization.rb
@@ -27,6 +27,10 @@ module ActiveSupport
@queue << o
end
+ def length
+ @queue.length
+ end
+
def pop; @queue.pop; end
end
@@ -68,10 +72,16 @@ module ActiveSupport
def start
@pool = @queue_size.times.map do |worker|
+ title = "Rails test worker #{worker}"
+
fork do
+ Process.setproctitle("#{title} - (starting)")
+
DRb.stop_service
- after_fork(worker)
+ begin
+ after_fork(worker)
+ rescue => setup_exception; end
queue = DRbObject.new_with_uri(@url)
@@ -79,7 +89,14 @@ module ActiveSupport
klass = job[0]
method = job[1]
reporter = job[2]
- result = Minitest.run_one_method(klass, method)
+
+ Process.setproctitle("#{title} - #{klass}##{method}")
+
+ result = klass.with_info_handler reporter do
+ Minitest.run_one_method(klass, method)
+ end
+
+ add_setup_exception(result, setup_exception) if setup_exception
begin
queue.record(reporter, result)
@@ -89,8 +106,12 @@ module ActiveSupport
end
queue.record(reporter, result)
end
+
+ Process.setproctitle("#{title} - (idle)")
end
ensure
+ Process.setproctitle("#{title} - (stopping)")
+
run_cleanup(worker)
end
end
@@ -103,7 +124,16 @@ module ActiveSupport
def shutdown
@queue_size.times { @queue << nil }
@pool.each { |pid| Process.waitpid pid }
+
+ if @queue.length > 0
+ raise "Queue not empty, but all workers have finished. This probably means that a worker crashed and #{@queue.length} tests were missed."
+ end
end
+
+ private
+ def add_setup_exception(result, setup_exception)
+ result.failures.prepend Minitest::UnexpectedError.new(setup_exception)
+ end
end
end
end