aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/testing
diff options
context:
space:
mode:
authorEileen Uchitelle <eileencodes@gmail.com>2018-08-13 08:56:49 -0400
committerEileen Uchitelle <eileencodes@gmail.com>2018-09-05 14:43:14 -0400
commit38f074f0a8ee85553d34a0a2b33ba2ece38e7bcf (patch)
tree2d2c0b236f0dc3f8dcb592d3ec0698a6d546c993 /activesupport/lib/active_support/testing
parent35870148b6b71b5b77c90fbbd1ac66b5882121f1 (diff)
downloadrails-38f074f0a8ee85553d34a0a2b33ba2ece38e7bcf.tar.gz
rails-38f074f0a8ee85553d34a0a2b33ba2ece38e7bcf.tar.bz2
rails-38f074f0a8ee85553d34a0a2b33ba2ece38e7bcf.zip
Ensure we always cleanup the databases
This commit moves the `run_cleanup` hook into an `ensure` block so we make sure to cleanup the databases even if an exception is raised while running the parallel tests.
Diffstat (limited to 'activesupport/lib/active_support/testing')
-rw-r--r--activesupport/lib/active_support/testing/parallelization.rb24
1 files changed, 13 insertions, 11 deletions
diff --git a/activesupport/lib/active_support/testing/parallelization.rb b/activesupport/lib/active_support/testing/parallelization.rb
index 1caac1feb3..beeb470659 100644
--- a/activesupport/lib/active_support/testing/parallelization.rb
+++ b/activesupport/lib/active_support/testing/parallelization.rb
@@ -65,22 +65,24 @@ module ActiveSupport
def start
@pool = @queue_size.times.map do |worker|
fork do
- DRb.stop_service
+ begin
+ DRb.stop_service
- after_fork(worker)
+ after_fork(worker)
- queue = DRbObject.new_with_uri(@url)
+ 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)
+ while job = queue.pop
+ klass = job[0]
+ method = job[1]
+ reporter = job[2]
+ result = Minitest.run_one_method(klass, method)
- queue.record(reporter, result)
+ queue.record(reporter, result)
+ end
+ ensure
+ run_cleanup(worker)
end
-
- run_cleanup(worker)
end
end
end