mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Show the chilled status of a String [ci skip]
This commit is contained in:
parent
990e11b60e
commit
e720a6b485
5 changed files with 17 additions and 54 deletions
|
@ -95,10 +95,8 @@ module Gem::BUNDLED_GEMS
|
|||
end
|
||||
|
||||
def self.warning?(name, specs: nil)
|
||||
# name can be a feature name or a file path with String or Pathname
|
||||
feature = File.path(name)
|
||||
# bootsnap expand `require "csv"` to `require "#{LIBDIR}/csv.rb"`
|
||||
name = feature.delete_prefix(LIBDIR).chomp(".rb").tr("/", "-")
|
||||
feature = File.path(name) # name can be a feature name or a file path with String or Pathname
|
||||
name = feature.tr("/", "-")
|
||||
name.sub!(LIBEXT, "")
|
||||
return if specs.include?(name)
|
||||
_t, path = $:.resolve_feature_path(feature)
|
||||
|
@ -111,7 +109,12 @@ module Gem::BUNDLED_GEMS
|
|||
else
|
||||
return
|
||||
end
|
||||
|
||||
# Warning feature is not working correctly with Bootsnap.
|
||||
# caller_locations returns:
|
||||
# lib/ruby/3.3.0+0/bundled_gems.rb:65:in `block (2 levels) in replace_require'
|
||||
# $GEM_HOME/gems/bootsnap-1.17.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'"
|
||||
# ...
|
||||
return if caller_locations(2).find {|c| c&.path.match?(/bootsnap/) }
|
||||
return if WARNED[name]
|
||||
WARNED[name] = true
|
||||
if gem == true
|
||||
|
@ -131,29 +134,11 @@ module Gem::BUNDLED_GEMS
|
|||
|
||||
if defined?(Bundler)
|
||||
msg += " Add #{gem} to your Gemfile or gemspec."
|
||||
|
||||
# We detect the gem name from caller_locations. We need to skip 2 frames like:
|
||||
# lib/ruby/3.3.0+0/bundled_gems.rb:90:in `warning?'",
|
||||
# lib/ruby/3.3.0+0/bundler/rubygems_integration.rb:247:in `block (2 levels) in replace_require'",
|
||||
#
|
||||
# Additionally, we need to skip Bootsnap and Zeitwerk if present, these
|
||||
# gems decorate Kernel#require, so they are not really the ones issuing
|
||||
# the require call users should be warned about. Those are upwards.
|
||||
frames_to_skip = 2
|
||||
location = nil
|
||||
Thread.each_caller_location do |cl|
|
||||
if frames_to_skip >= 1
|
||||
frames_to_skip -= 1
|
||||
next
|
||||
end
|
||||
|
||||
unless cl.path.match?(/bootsnap|zeitwerk/)
|
||||
location = cl.path
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if location && File.file?(location) && !location.start_with?(Gem::BUNDLED_GEMS::LIBDIR)
|
||||
location = caller_locations(3,1)[0]&.path
|
||||
if File.file?(location) && !location.start_with?(Gem::BUNDLED_GEMS::LIBDIR)
|
||||
caller_gem = nil
|
||||
Gem.path.each do |path|
|
||||
if location =~ %r{#{path}/gems/([\w\-\.]+)}
|
||||
|
|
|
@ -119,6 +119,10 @@ class RbInspector(LLDBInterface):
|
|||
self.result.write('T_STRING: %s' % flaginfo)
|
||||
tRString = self.target.FindFirstType("struct RString").GetPointerType()
|
||||
|
||||
chilled = self.ruby_globals["RUBY_FL_USER3"]
|
||||
if (rval.flags & chilled) != 0:
|
||||
self.result.write("[CHILLED] ")
|
||||
|
||||
rb_enc_mask = self.ruby_globals["RUBY_ENCODING_MASK"]
|
||||
rb_enc_shift = self.ruby_globals["RUBY_ENCODING_SHIFT"]
|
||||
encidx = ((rval.flags & rb_enc_mask) >> rb_enc_shift)
|
||||
|
|
|
@ -2,44 +2,30 @@
|
|||
|
||||
echo "* Show warning require and LoadError"
|
||||
ruby test_warn_bundled_gems.rb
|
||||
echo
|
||||
|
||||
echo "* Show warning when bundled gems called as dependency"
|
||||
ruby test_warn_dependency.rb
|
||||
echo
|
||||
|
||||
echo "* Show warning sub-feature like bigdecimal/util"
|
||||
ruby test_warn_sub_feature.rb
|
||||
echo
|
||||
|
||||
echo "* Show warning dash gem like net/smtp"
|
||||
ruby test_warn_dash_gem.rb
|
||||
echo
|
||||
|
||||
echo "* Show warning when bundle exec with ruby and script"
|
||||
bundle exec ruby test_warn_bundle_exec.rb
|
||||
echo
|
||||
|
||||
echo "* Show warning when bundle exec with shebang's script"
|
||||
bundle exec ./test_warn_bundle_exec_shebang.rb
|
||||
echo
|
||||
|
||||
echo "* Show warning with bootsnap"
|
||||
ruby test_warn_bootsnap.rb
|
||||
echo
|
||||
|
||||
echo "* Show warning with zeitwerk"
|
||||
ruby test_warn_zeitwerk.rb
|
||||
echo
|
||||
|
||||
echo "* Don't show warning bundled gems on Gemfile"
|
||||
ruby test_no_warn_dependency.rb
|
||||
echo
|
||||
|
||||
echo "* Don't show warning with bootsnap"
|
||||
ruby test_no_warn_bootsnap.rb
|
||||
|
||||
echo "* Don't show warning with net/smtp when net-smtp on Gemfile"
|
||||
ruby test_no_warn_dash_gem.rb
|
||||
echo
|
||||
|
||||
echo "* Don't show warning bigdecimal/util when bigdecimal on Gemfile"
|
||||
ruby test_no_warn_sub_feature.rb
|
||||
echo
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
require "bundler/inline"
|
||||
|
||||
gemfile do
|
||||
source "https://rubygems.org"
|
||||
gem "zeitwerk", require: false
|
||||
end
|
||||
|
||||
require "zeitwerk"
|
||||
loader = Zeitwerk::Loader.for_gem(warn_on_extra_files: false)
|
||||
loader.setup
|
||||
|
||||
require 'csv'
|
Loading…
Add table
Add a link
Reference in a new issue