1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Clean up AR's isolated test runner

This commit is contained in:
Matthew Draper 2019-03-05 01:40:36 +10:30
parent af986325e9
commit 99d84c6ab2
2 changed files with 21 additions and 3 deletions

View file

@ -80,9 +80,19 @@ end
require "bundler/setup" unless defined?(Bundler)
# Every test file loads this first, so doing it post-fork gains
# us nothing.
require "cases/helper"
# Every test file loads "cases/helper" first, so doing it
# post-fork gains us nothing.
# We need to dance around minitest autorun, though.
require "minitest"
Minitest.instance_eval do
alias _original_autorun autorun
def autorun
# no-op
end
require "cases/helper"
alias autorun _original_autorun
end
failing_files = []
@ -115,6 +125,8 @@ end
ARGV.clear.concat test_options
Rake.application = nil
Minitest.autorun
load file
}

View file

@ -11,6 +11,12 @@ class TestUnconnectedAdapter < ActiveRecord::TestCase
def setup
@underlying = ActiveRecord::Base.connection
@specification = ActiveRecord::Base.remove_connection
# Clear out connection info from other pids (like a fork parent) too
pool_map = ActiveRecord::Base.connection_handler.instance_variable_get(:@owner_to_pool)
(pool_map.keys - [Process.pid]).each do |other_pid|
pool_map.delete(other_pid)
end
end
teardown do