[前][次][番号順一覧][スレッド一覧]

ruby-changes:72797

From: Ilya <ko1@a...>
Date: Wed, 3 Aug 2022 06:56:44 +0900 (JST)
Subject: [ruby-changes:72797] 4f00ee8d47 (master): [rubygems/rubygems] fix platform matching for index specs

https://git.ruby-lang.org/ruby.git/commit/?id=4f00ee8d47

From 4f00ee8d470f4ad5040c0df4cac2cf802b3cbdaf Mon Sep 17 00:00:00 2001
From: Ilya Dyakonov <ilushkadyakonov@g...>
Date: Mon, 1 Aug 2022 09:54:21 +0100
Subject: [rubygems/rubygems] fix platform matching for index specs

https://github.com/rubygems/rubygems/commit/f087f1b590
---
 lib/rubygems/resolver/index_specification.rb           |  5 +++--
 test/rubygems/test_gem_resolver_index_specification.rb |  2 +-
 test/rubygems/test_gem_resolver_installer_set.rb       | 13 +++++++++++++
 3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/lib/rubygems/resolver/index_specification.rb b/lib/rubygems/resolver/index_specification.rb
index e8c3b35f7e..0fc758dfd3 100644
--- a/lib/rubygems/resolver/index_specification.rb
+++ b/lib/rubygems/resolver/index_specification.rb
@@ -21,7 +21,8 @@ class Gem::Resolver::IndexSpecification < Gem::Resolver::Specification https://github.com/ruby/ruby/blob/trunk/lib/rubygems/resolver/index_specification.rb#L21
     @name = name
     @version = version
     @source = source
-    @platform = platform.to_s
+    @platform = Gem::Platform.new(platform.to_s)
+    @original_platform = platform.to_s
 
     @spec = nil
   end
@@ -91,7 +92,7 @@ class Gem::Resolver::IndexSpecification < Gem::Resolver::Specification https://github.com/ruby/ruby/blob/trunk/lib/rubygems/resolver/index_specification.rb#L92
   def spec # :nodoc:
     @spec ||=
       begin
-        tuple = Gem::NameTuple.new @name, @version, @platform
+        tuple = Gem::NameTuple.new @name, @version, @original_platform
 
         @source.fetch_spec tuple
       end
diff --git a/test/rubygems/test_gem_resolver_index_specification.rb b/test/rubygems/test_gem_resolver_index_specification.rb
index 339445cb44..b479757bd5 100644
--- a/test/rubygems/test_gem_resolver_index_specification.rb
+++ b/test/rubygems/test_gem_resolver_index_specification.rb
@@ -26,7 +26,7 @@ class TestGemResolverIndexSpecification < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_resolver_index_specification.rb#L26
     spec = Gem::Resolver::IndexSpecification.new(
       set, "rails", version, source, Gem::Platform.local)
 
-    assert_equal Gem::Platform.local.to_s, spec.platform
+    assert_equal Gem::Platform.local, spec.platform
   end
 
   def test_install
diff --git a/test/rubygems/test_gem_resolver_installer_set.rb b/test/rubygems/test_gem_resolver_installer_set.rb
index 8d84c28172..32e1faa28d 100644
--- a/test/rubygems/test_gem_resolver_installer_set.rb
+++ b/test/rubygems/test_gem_resolver_installer_set.rb
@@ -51,6 +51,19 @@ class TestGemResolverInstallerSet < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_resolver_installer_set.rb#L51
     assert_equal %w[a-1], set.always_install.map {|s| s.full_name }
   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
     spec_fetcher do |fetcher|
       fetcher.gem "a", 1
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]