1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[rubygems/rubygems] fix platform matching for index specs

https://github.com/rubygems/rubygems/commit/f087f1b590
This commit is contained in:
Ilya Dyakonov 2022-08-01 09:54:21 +01:00 committed by git
parent 20936eb3a9
commit 4f00ee8d47
3 changed files with 17 additions and 3 deletions

View file

@ -21,7 +21,8 @@ class Gem::Resolver::IndexSpecification < Gem::Resolver::Specification
@name = name @name = name
@version = version @version = version
@source = source @source = source
@platform = platform.to_s @platform = Gem::Platform.new(platform.to_s)
@original_platform = platform.to_s
@spec = nil @spec = nil
end end
@ -91,7 +92,7 @@ class Gem::Resolver::IndexSpecification < Gem::Resolver::Specification
def spec # :nodoc: def spec # :nodoc:
@spec ||= @spec ||=
begin begin
tuple = Gem::NameTuple.new @name, @version, @platform tuple = Gem::NameTuple.new @name, @version, @original_platform
@source.fetch_spec tuple @source.fetch_spec tuple
end end

View file

@ -26,7 +26,7 @@ class TestGemResolverIndexSpecification < Gem::TestCase
spec = Gem::Resolver::IndexSpecification.new( spec = Gem::Resolver::IndexSpecification.new(
set, "rails", version, source, Gem::Platform.local) set, "rails", version, source, Gem::Platform.local)
assert_equal Gem::Platform.local.to_s, spec.platform assert_equal Gem::Platform.local, spec.platform
end end
def test_install def test_install

View file

@ -51,6 +51,19 @@ class TestGemResolverInstallerSet < Gem::TestCase
assert_equal %w[a-1], set.always_install.map {|s| s.full_name } assert_equal %w[a-1], set.always_install.map {|s| s.full_name }
end end
def test_add_always_install_index_spec_platform
a_1_local, a_1_local_gem = util_gem "a", 1 do |s|
s.platform = Gem::Platform.local
end
FileUtils.mv a_1_local_gem, @tempdir
set = Gem::Resolver::InstallerSet.new :both
set.add_always_install dep("a")
assert_equal [Gem::Platform.local], set.always_install.map {|s| s.platform }
end
def test_add_always_install_prerelease def test_add_always_install_prerelease
spec_fetcher do |fetcher| spec_fetcher do |fetcher|
fetcher.gem "a", 1 fetcher.gem "a", 1