Deletes AS::Dependencies.warnings_on_first_load

This commit is contained in:
Xavier Noria 2021-03-10 07:55:29 +01:00
parent dc7817cb42
commit 482e081aaa
3 changed files with 1 additions and 48 deletions

@ -48,9 +48,6 @@ def self.unload_interlock
# :nodoc:
# Should we turn on Ruby warnings on the first load of dependent files?
mattr_accessor :warnings_on_first_load, default: false
# All files ever loaded.
mattr_accessor :history, default: Set.new
@ -378,16 +375,10 @@ def require_or_load(file_name, const_path = nil)
begin
if load?
# Enable warnings if this file has not been loaded before and
# warnings_on_first_load is set.
load_args = ["#{file_name}.rb"]
load_args << const_path unless const_path.nil?
if !warnings_on_first_load || history.include?(expanded)
result = load_file(*load_args)
else
enable_warnings { result = load_file(*load_args) }
end
else
result = require file_name
end

@ -104,43 +104,6 @@ def test_dependency_which_raises_exception_isnt_added_to_loaded_set
end
end
def test_warnings_should_be_enabled_on_first_load
with_loading "dependencies" do
old_warnings, ActiveSupport::Dependencies.warnings_on_first_load = ActiveSupport::Dependencies.warnings_on_first_load, true
filename = "check_warnings"
expanded = File.expand_path("dependencies/#{filename}", __dir__)
$check_warnings_load_count = 0
assert_not ActiveSupport::Dependencies.loaded.include?(expanded)
assert_not ActiveSupport::Dependencies.history.include?(expanded)
silence_warnings { require_dependency filename }
assert_equal 1, $check_warnings_load_count
assert_equal true, $checked_verbose, "On first load warnings should be enabled."
assert_includes ActiveSupport::Dependencies.loaded, expanded
ActiveSupport::Dependencies.clear
assert_not ActiveSupport::Dependencies.loaded.include?(expanded)
assert_includes ActiveSupport::Dependencies.history, expanded
silence_warnings { require_dependency filename }
assert_equal 2, $check_warnings_load_count
assert_nil $checked_verbose, "After first load warnings should be left alone."
assert_includes ActiveSupport::Dependencies.loaded, expanded
ActiveSupport::Dependencies.clear
assert_not ActiveSupport::Dependencies.loaded.include?(expanded)
assert_includes ActiveSupport::Dependencies.history, expanded
enable_warnings { require_dependency filename }
assert_equal 3, $check_warnings_load_count
assert_equal true, $checked_verbose, "After first load warnings should be left alone."
assert_includes ActiveSupport::Dependencies.loaded, expanded
ActiveSupport::Dependencies.warnings_on_first_load = old_warnings
end
end
def test_mutual_dependencies_dont_infinite_loop
with_loading "dependencies" do
$mutual_dependencies_count = 0

@ -604,7 +604,6 @@ For example, the dependencies mechanism uses them:
```ruby
module ActiveSupport
module Dependencies
mattr_accessor :warnings_on_first_load
mattr_accessor :history
mattr_accessor :loaded
mattr_accessor :mechanism