diff options
| author | Étienne Barrié <etienne.barrie@gmail.com> | 2025-09-08 12:17:24 +0200 |
|---|---|---|
| committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2025-09-11 11:54:49 +0900 |
| commit | 3097a7bd125885ae4a3256542cd4d4aebd1d82da (patch) | |
| tree | c3663a7f7746905b8f7a8b9df5c23203a0887c2c | |
| parent | fa5bebbcfad4eaa4c259444148a7391ae12e3759 (diff) | |
[ruby/json] Fix deprecation warning backtrace
The gem root was including the test/ directory, so lines from tests were
skipped, and the deprecation warnings were shown as coming from the test
framework.
https://github.com/ruby/json/commit/2ec31a7363
Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
| -rw-r--r-- | ext/json/lib/json/common.rb | 2 | ||||
| -rw-r--r-- | test/json/json_parser_test.rb | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/ext/json/lib/json/common.rb b/ext/json/lib/json/common.rb index 1f82c46240..60178c2a59 100644 --- a/ext/json/lib/json/common.rb +++ b/ext/json/lib/json/common.rb @@ -97,7 +97,7 @@ module JSON class << self def deprecation_warning(message, uplevel = 3) # :nodoc: - gem_root = File.expand_path("../../../", __FILE__) + "/" + gem_root = File.expand_path("..", __dir__) + "/" caller_locations(uplevel, 10).each do |frame| if frame.path.nil? || frame.path.start_with?(gem_root) || frame.path.end_with?("/truffle/cext_ruby.rb", ".c") uplevel += 1 diff --git a/test/json/json_parser_test.rb b/test/json/json_parser_test.rb index 3c60fec875..45474c9820 100644 --- a/test/json/json_parser_test.rb +++ b/test/json/json_parser_test.rb @@ -347,7 +347,7 @@ class JSONParserTest < Test::Unit::TestCase assert_equal expected_sym, parse('{"a": 1, "a": 2}', symbolize_names: true) end - if RUBY_ENGINE == 'RUBY_ENGINE' + if RUBY_ENGINE == 'ruby' assert_deprecated_warning(/#{File.basename(__FILE__)}\:#{__LINE__ + 1}/) do assert_equal expected, parse('{"a": 1, "a": 2}') end |
