From e460c77d380db3c2c3ab3a648214b81dae649b7a Mon Sep 17 00:00:00 2001 From: Aric Walker Date: Sun, 14 Apr 2019 16:03:06 -0600 Subject: If exception occurs during setup, add to each test executed Resolves https://github.com/rails/rails/issues/35835 If an exception occurs during `parallelize_setup` make sure to catch that exception and apply it to the result of each successive test run. This results in marking all of the tests as failed to bring attention to the issue & ensure it is addressed before proceeding. --- activesupport/lib/active_support/testing/parallelization.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/testing/parallelization.rb b/activesupport/lib/active_support/testing/parallelization.rb index 08285b2f52..e760bf5ce3 100644 --- a/activesupport/lib/active_support/testing/parallelization.rb +++ b/activesupport/lib/active_support/testing/parallelization.rb @@ -71,7 +71,9 @@ module ActiveSupport fork do DRb.stop_service - after_fork(worker) + begin + after_fork(worker) + rescue => setup_exception; end queue = DRbObject.new_with_uri(@url) @@ -83,6 +85,8 @@ module ActiveSupport Minitest.run_one_method(klass, method) end + add_setup_exception(result, setup_exception) if setup_exception + begin queue.record(reporter, result) rescue DRb::DRbConnError @@ -106,6 +110,11 @@ module ActiveSupport @queue_size.times { @queue << nil } @pool.each { |pid| Process.waitpid pid } end + + private + def add_setup_exception(result, setup_exception) + result.failures.prepend Minitest::UnexpectedError.new(setup_exception) + end end end end -- cgit v1.2.3