Skip to content

Commit

Permalink
If exception occurs during setup, add to each test executed
Browse files Browse the repository at this point in the history
Resolves #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.
  • Loading branch information
aricwalker committed Apr 18, 2019
1 parent 0f39a74 commit e460c77
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion activesupport/lib/active_support/testing/parallelization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ def start
fork do
DRb.stop_service

after_fork(worker)
begin
after_fork(worker)
rescue => setup_exception; end

queue = DRbObject.new_with_uri(@url)

Expand All @@ -83,6 +85,8 @@ def start
Minitest.run_one_method(klass, method)
end

add_setup_exception(result, setup_exception) if setup_exception

begin
queue.record(reporter, result)
rescue DRb::DRbConnError
Expand All @@ -106,6 +110,11 @@ def shutdown
@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

0 comments on commit e460c77

Please sign in to comment.