summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2021-01-14 13:38:47 +0900
committerNARUSE, Yui <nurse@users.noreply.github.com>2021-01-14 16:44:42 +0900
commit29777cb32ad6417c3583a81b01127c93cd667e77 (patch)
tree14d9c552ecbd1e0c8c0e6910364bd796f4840cff
parent93dcf0828dc8e627e0c24497795d927911a9d993 (diff)
Merge RubyGems-3.2.5
-rw-r--r--lib/rubygems.rb2
-rw-r--r--lib/rubygems/commands/setup_command.rb4
-rw-r--r--lib/rubygems/specification.rb32
-rw-r--r--lib/rubygems/test_case.rb15
-rw-r--r--test/rubygems/test_gem_commands_setup_command.rb9
-rw-r--r--test/rubygems/test_gem_specification.rb8
6 files changed, 50 insertions, 20 deletions
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index 0c3e5858d4..6d72006dd4 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -8,7 +8,7 @@
require 'rbconfig'
module Gem
- VERSION = "3.2.4".freeze
+ VERSION = "3.2.5".freeze
end
# Must be first since it unloads the prelude from 1.9.2
diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb
index b5af43d7b7..47e215c149 100644
--- a/lib/rubygems/commands/setup_command.rb
+++ b/lib/rubygems/commands/setup_command.rb
@@ -375,9 +375,7 @@ By default, this RubyGems will install gem as:
specs_dir = File.join(options[:destdir], specs_dir) unless Gem.win_platform?
mkdir_p specs_dir, :mode => 0755
- bundler_spec = Gem::Specification.load("bundler/bundler.gemspec")
- bundler_spec.files = Dir.chdir("bundler") { Dir["{*.md,{lib,exe}/**/*}"] }
- bundler_spec.executables -= %w[bundler bundle_ruby]
+ bundler_spec = Dir.chdir("bundler") { Gem::Specification.load("bundler.gemspec") }
# Remove bundler-*.gemspec in default specification directory.
Dir.entries(specs_dir).
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
index d59f57c49f..4e1a3a3801 100644
--- a/lib/rubygems/specification.rb
+++ b/lib/rubygems/specification.rb
@@ -182,6 +182,7 @@ class Gem::Specification < Gem::BasicSpecification
@@default_value[k].nil?
end
+ @@stubs = nil
@@stubs_by_name = {}
# Sentinel object to represent "not found" stubs
@@ -800,10 +801,8 @@ class Gem::Specification < Gem::BasicSpecification
def self.stubs
@@stubs ||= begin
pattern = "*.gemspec"
- stubs = installed_stubs(dirs, pattern) + default_stubs(pattern)
- stubs = stubs.uniq {|stub| stub.full_name }
+ stubs = stubs_for_pattern(pattern, false)
- _resort!(stubs)
@@stubs_by_name = stubs.select {|s| Gem::Platform.match_spec? s }.group_by(&:name)
stubs
end
@@ -820,26 +819,31 @@ class Gem::Specification < Gem::BasicSpecification
end
end
- EMPTY = [].freeze # :nodoc:
-
##
# Returns a Gem::StubSpecification for installed gem named +name+
# only returns stubs that match Gem.platforms
def self.stubs_for(name)
- if @@stubs_by_name[name]
- @@stubs_by_name[name]
+ if @@stubs
+ @@stubs_by_name[name] || []
else
- pattern = "#{name}-*.gemspec"
- stubs = installed_stubs(dirs, pattern).select {|s| Gem::Platform.match_spec? s } + default_stubs(pattern)
- stubs = stubs.uniq {|stub| stub.full_name }.group_by(&:name)
- stubs.each_value {|v| _resort!(v) }
-
- @@stubs_by_name.merge! stubs
- @@stubs_by_name[name] ||= EMPTY
+ @@stubs_by_name[name] ||= stubs_for_pattern("#{name}-*.gemspec")
end
end
+ ##
+ # Finds stub specifications matching a pattern from the standard locations,
+ # optionally filtering out specs not matching the current platform
+ #
+ def self.stubs_for_pattern(pattern, match_platform = true) # :nodoc:
+ installed_stubs = installed_stubs(Gem::Specification.dirs, pattern)
+ installed_stubs.select! {|s| Gem::Platform.match_spec? s } if match_platform
+ stubs = installed_stubs + default_stubs(pattern)
+ stubs = stubs.uniq {|stub| stub.full_name }
+ _resort!(stubs)
+ stubs
+ end
+
def self._resort!(specs) # :nodoc:
specs.sort! do |a, b|
names = a.name <=> b.name
diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb
index 6523c515be..0f3791f03d 100644
--- a/lib/rubygems/test_case.rb
+++ b/lib/rubygems/test_case.rb
@@ -26,7 +26,20 @@ begin
rescue LoadError
end
-require 'bundler'
+if File.exist?(bundler_gemspec)
+ require_relative '../../bundler/lib/bundler'
+else
+ require 'bundler'
+end
+
+# Enable server plugin needed for bisection
+if ENV["RG_BISECT_SERVER_PLUGIN"]
+ require ENV["RG_BISECT_SERVER_PLUGIN"]
+
+ Minitest.extensions << "server"
+end
+
+ENV["MT_NO_PLUGINS"] = "true"
require 'minitest/autorun'
diff --git a/test/rubygems/test_gem_commands_setup_command.rb b/test/rubygems/test_gem_commands_setup_command.rb
index 66a6707eb8..29850c9074 100644
--- a/test/rubygems/test_gem_commands_setup_command.rb
+++ b/test/rubygems/test_gem_commands_setup_command.rb
@@ -24,6 +24,7 @@ class TestGemCommandsSetupCommand < Gem::TestCase
lib/rubygems/test_case.rb
lib/rubygems/ssl_certs/rubygems.org/foo.pem
bundler/exe/bundle
+ bundler/exe/bundler
bundler/lib/bundler.rb
bundler/lib/bundler/b.rb
bundler/bin/bundler/man/bundle-b.1
@@ -41,7 +42,7 @@ class TestGemCommandsSetupCommand < Gem::TestCase
gemspec.name = "bundler"
gemspec.version = BUNDLER_VERS
gemspec.bindir = "exe"
- gemspec.executables = ["bundle"]
+ gemspec.executables = ["bundle", "bundler"]
File.open 'bundler/bundler.gemspec', 'w' do |io|
io.puts gemspec.to_ruby
@@ -135,6 +136,7 @@ class TestGemCommandsSetupCommand < Gem::TestCase
exec_line = out.shift until exec_line == "RubyGems installed the following executables:"
assert_equal "\t#{default_gem_bin_path}", out.shift
assert_equal "\t#{default_bundle_bin_path}", out.shift
+ assert_equal "\t#{default_bundler_bin_path}", out.shift
end
def test_env_shebang_flag
@@ -152,6 +154,7 @@ class TestGemCommandsSetupCommand < Gem::TestCase
bin_env = win_platform? ? "" : %w[/usr/bin/env /bin/env].find {|f| File.executable?(f) } + " "
assert_match %r{\A#!\s*#{bin_env}#{ruby_exec}}, File.read(default_gem_bin_path)
assert_match %r{\A#!\s*#{bin_env}#{ruby_exec}}, File.read(default_bundle_bin_path)
+ assert_match %r{\A#!\s*#{bin_env}#{ruby_exec}}, File.read(default_bundler_bin_path)
assert_match %r{\A#!\s*#{bin_env}#{ruby_exec}}, File.read(gem_bin_path)
end
@@ -387,4 +390,8 @@ class TestGemCommandsSetupCommand < Gem::TestCase
def default_bundle_bin_path
File.join @install_dir, 'bin', 'bundle'
end
+
+ def default_bundler_bin_path
+ File.join @install_dir, 'bin', 'bundler'
+ end
end unless Gem.java_platform?
diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb
index 374d58d38f..763b62c22b 100644
--- a/test/rubygems/test_gem_specification.rb
+++ b/test/rubygems/test_gem_specification.rb
@@ -1161,6 +1161,14 @@ dependencies: []
Gem::Specification.class_variable_set(:@@stubs, nil)
end
+ def test_self_stubs_for_no_lazy_loading_after_all_specs_setup
+ Gem::Specification.all = [util_spec('a', '1')]
+
+ save_gemspec('b-1', '1', File.join(Gem.dir, 'specifications')){|s| s.name = 'b' }
+
+ assert_equal [], Gem::Specification.stubs_for('b').map {|s| s.full_name }
+ end
+
def test_self_stubs_for_mult_platforms
# gems for two different platforms are installed with --user-install
# the correct one should be returned in the array