Skip to content

Commit

Permalink
fix platform matching for index specs
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilushkanama committed Aug 1, 2022
1 parent a121616 commit f087f1b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/rubygems/resolver/index_specification.rb
Expand Up @@ -21,7 +21,8 @@ def initialize(set, name, version, source, platform)
@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
Expand Down Expand Up @@ -91,7 +92,7 @@ def pretty_print(q) # :nodoc:
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
Expand Down
2 changes: 1 addition & 1 deletion test/rubygems/test_gem_resolver_index_specification.rb
Expand Up @@ -26,7 +26,7 @@ def test_initialize_platform
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
Expand Down
13 changes: 13 additions & 0 deletions test/rubygems/test_gem_resolver_installer_set.rb
Expand Up @@ -51,6 +51,19 @@ def test_add_always_install_platform
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
Expand Down

0 comments on commit f087f1b

Please sign in to comment.