diff options
author | Hiroshi SHIBATA <[email protected]> | 2025-01-08 11:02:00 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2025-01-08 11:55:39 +0900 |
commit | 4a02a72ca57daf4984a3b2245dbc418fe35e6295 (patch) | |
tree | d839fcd66942b6b894dafdf57dd5f16c9bc68c36 | |
parent | aaf36f4f8eb585ef598aa9f2d973adf92a868de3 (diff) |
Dont't use stub constants like LIBDIR in bundled_gems.rb
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/12529
-rw-r--r-- | lib/bundled_gems.rb | 12 | ||||
-rw-r--r-- | spec/bundled_gems_spec.rb | 16 |
2 files changed, 12 insertions, 16 deletions
diff --git a/lib/bundled_gems.rb b/lib/bundled_gems.rb index e09402b1a6..ff13a0873d 100644 --- a/lib/bundled_gems.rb +++ b/lib/bundled_gems.rb @@ -51,14 +51,8 @@ module Gem::BUNDLED_GEMS # :nodoc: WARNED = {} # unfrozen conf = ::RbConfig::CONFIG - if ENV["TEST_BUNDLED_GEMS_FAKE_RBCONFIG"] - LIBDIR = (File.expand_path(File.join(__dir__, "..", "lib")) + "/").freeze - rubyarchdir = $LOAD_PATH.find{|path| path.include?(".ext/common") } - ARCHDIR = (File.expand_path(rubyarchdir) + "/").freeze - else - LIBDIR = (conf["rubylibdir"] + "/").freeze - ARCHDIR = (conf["rubyarchdir"] + "/").freeze - end + LIBDIR = (conf["rubylibdir"] + "/").freeze + ARCHDIR = (conf["rubyarchdir"] + "/").freeze dlext = [conf["DLEXT"], "so"].uniq DLEXT = /\.#{Regexp.union(dlext)}\z/ LIBEXT = /\.#{Regexp.union("rb", *dlext)}\z/ @@ -229,8 +223,6 @@ module Gem::BUNDLED_GEMS # :nodoc: msg end - - freeze end # for RubyGems without Bundler environment. diff --git a/spec/bundled_gems_spec.rb b/spec/bundled_gems_spec.rb index 3f1982adf8..eda2ac41f6 100644 --- a/spec/bundled_gems_spec.rb +++ b/spec/bundled_gems_spec.rb @@ -20,7 +20,6 @@ RSpec.configure do |config| config.before(:suite) do Gem.ruby = ENV["RUBY"] if ENV["RUBY"] - ENV["TEST_BUNDLED_GEMS_FAKE_RBCONFIG"] = "true" require_relative "bundler/support/rubygems_ext" Spec::Rubygems.test_setup @@ -59,6 +58,11 @@ RSpec.describe "bundled_gems.rb" do def script(code, options = {}) options[:artifice] ||= "compact_index" code = <<~RUBY + Gem::BUNDLED_GEMS.send(:remove_const, :LIBDIR) + Gem::BUNDLED_GEMS.send(:remove_const, :ARCHDIR) + Gem::BUNDLED_GEMS.const_set(:LIBDIR, File.expand_path(File.join(__dir__, "../../..", "lib")) + "/") + Gem::BUNDLED_GEMS.const_set(:ARCHDIR, File.expand_path($LOAD_PATH.find{|path| path.include?(".ext/common") }) + "/") + require 'bundler/inline' #{code} @@ -80,9 +84,9 @@ RSpec.describe "bundled_gems.rb" do RUBY expect(err).to include(/csv was loaded from (.*) from Ruby 3.4.0/) - expect(err).to include(/-e:8/) + expect(err).to include(/-e:13/) expect(err).to include(/ostruct was loaded from (.*) from Ruby 3.5.0/) - expect(err).to include(/-e:11/) + expect(err).to include(/-e:16/) end it "Show warning when bundled gems called as dependency" do @@ -118,7 +122,7 @@ RSpec.describe "bundled_gems.rb" do RUBY expect(err).to include(/net\/smtp was loaded from (.*) from Ruby 3.1.0/) - expect(err).to include(/-e:8/) + expect(err).to include(/-e:13/) expect(err).to include("You can add net-smtp") end @@ -134,7 +138,7 @@ RSpec.describe "bundled_gems.rb" do RUBY expect(err).to include(/fiddle\/import is found in fiddle, (.*) part of the default gems starting from Ruby 3\.5\.0/) - expect(err).to include(/-e:7/) + expect(err).to include(/-e:12/) end it "Show warning when bundle exec with ruby and script" do @@ -195,7 +199,7 @@ RSpec.describe "bundled_gems.rb" do RUBY expect(err).to include(/ostruct was loaded from (.*) from Ruby 3.5.0/) - expect(err).to include(/-e:12/) + expect(err).to include(/-e:17/) end it "Don't show warning when bundled gems called as dependency" do |