Merge pull request #51619 from Earlopain/ruby-3.4-backtraces

Filter internal frames in deprecation warnings for Ruby 3.4
This commit is contained in:
Rafael Mendonça França 2024-04-23 17:52:58 -03:00 committed by GitHub
commit fa23f0fdd0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 1 deletions

View File

@ -172,7 +172,7 @@ module ActiveSupport
LIB_DIR = RbConfig::CONFIG["libdir"]
def ignored_callstack?(path)
path.start_with?(RAILS_GEM_ROOT, LIB_DIR)
path.start_with?(RAILS_GEM_ROOT, LIB_DIR) || path.include?("<internal:")
end
end
end

View File

@ -975,11 +975,22 @@ class DeprecationTest < ActiveSupport::TestCase
end
end
test "warn deprecation can blame code from internal methods" do
@deprecator.behavior = ->(message, *) { @message = message }
method_that_emits_deprecation_with_internal_method(@deprecator)
assert_not_includes(@message, "internal")
end
private
def method_that_emits_deprecation(deprecator)
deprecator.warn
end
def method_that_emits_deprecation_with_internal_method(deprecator)
[1].each { deprecator.warn }
end
def with_rails_application_deprecators(&block)
application = Struct.new(:deprecators).new(ActiveSupport::Deprecation::Deprecators.new)
rails = Struct.new(:application).new(application)