summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <[email protected]>2024-03-25 14:33:20 +0900
committerNobuyoshi Nakada <[email protected]>2024-03-25 14:33:20 +0900
commite720a6b48582900efd1bd326210644b2fc0f2c5d ()
treed6759ab42ea4b11e52ec5fa024f02cffb01a3cfb
parent990e11b60eae06d7e8205405fc99320267b5843b (diff)
Show the chilled status of a String [ci skip]
-rw-r--r--lib/bundled_gems.rb35
-rw-r--r--misc/lldb_rb/utils.py4
-rwxr-xr-xtool/test_for_warn_bundled_gems/test.sh20
-rw-r--r--tool/test_for_warn_bundled_gems/test_no_warn_bootsnap.rb (renamed from tool/test_for_warn_bundled_gems/test_warn_bootsnap.rb)0
-rw-r--r--tool/test_for_warn_bundled_gems/test_warn_zeitwerk.rb12
5 files changed, 17 insertions, 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("/", "-")
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
-
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)
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()
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 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'