Skip to content

Commit

Permalink
move formatting logic from Gem::Platform.local to Gem::Platform.initi…
Browse files Browse the repository at this point in the history
…alize
  • Loading branch information
gustavothecoder committed May 27, 2023
1 parent 76ee89c commit 718379d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions bundler/spec/resolver/platform_spec.rb
Expand Up @@ -24,7 +24,7 @@
dep "nokogiri"
platforms "mswin32"

should_resolve_as %w[nokogiri-1.4.2.1-x86-mswin32]
should_resolve_as %w[nokogiri-1.4.2.1-x86-mswin32-60]
end
end

Expand Down Expand Up @@ -353,7 +353,7 @@
# win32 is hardcoded to get CPU x86 in rubygems
platforms "mswin32"
dep "thin"
should_resolve_as %w[thin-1.2.7-x86-mswin32]
should_resolve_as %w[thin-1.2.7-x86-mswin32-60]
end

it "finds mingw gems" do
Expand Down
2 changes: 1 addition & 1 deletion lib/rubygems/platform.rb
Expand Up @@ -14,7 +14,6 @@ class Gem::Platform

def self.local
arch = RbConfig::CONFIG["arch"]
arch = "#{arch}_60" if /mswin(?:32|64)$/.match?(arch)
@local ||= new(arch)
end

Expand Down Expand Up @@ -70,6 +69,7 @@ def initialize(arch)
when Array then
@cpu, @os, @version = arch
when String then # Update Bundler::Standalone#add_arch_formatter whenever this case is changed.
arch = "#{arch}_60" if /mswin(?:32|64)$/.match?(arch)
arch = arch.split "-"

if arch.length > 2 && arch.last !~ /\d+(\.\d+)?$/ # reassemble x86-linux-{libc}
Expand Down
10 changes: 5 additions & 5 deletions test/rubygems/test_gem_platform.rb
Expand Up @@ -123,17 +123,17 @@ def test_initialize
"i386-linux-gnu" => ["x86", "linux", "gnu"],
"i386-mingw32" => ["x86", "mingw32", nil],
"x64-mingw-ucrt" => ["x64", "mingw", "ucrt"],
"i386-mswin32" => ["x86", "mswin32", nil],
"i386-mswin32" => ["x86", "mswin32", "60"],
"i386-mswin32_80" => ["x86", "mswin32", "80"],
"i386-mswin32-80" => ["x86", "mswin32", "80"],
"x86-mswin32" => ["x86", "mswin32", nil],
"x86-mswin32" => ["x86", "mswin32", "60"],
"x86-mswin32_60" => ["x86", "mswin32", "60"],
"x86-mswin32-60" => ["x86", "mswin32", "60"],
"i386-netbsdelf" => ["x86", "netbsdelf", nil],
"i386-openbsd4.0" => ["x86", "openbsd", "4.0"],
"i386-solaris2.10" => ["x86", "solaris", "2.10"],
"i386-solaris2.8" => ["x86", "solaris", "2.8"],
"mswin32" => ["x86", "mswin32", nil],
"mswin32" => ["x86", "mswin32", "60"],
"x86_64-linux" => ["x86_64", "linux", nil],
"x86_64-linux-gnu" => ["x86_64", "linux", "gnu"],
"x86_64-linux-musl" => ["x86_64", "linux", "musl"],
Expand All @@ -155,7 +155,7 @@ def test_initialize
end

def test_initialize_command_line
expected = ["x86", "mswin32", nil]
expected = ["x86", "mswin32", "60"]

platform = Gem::Platform.new "i386-mswin32"

Expand All @@ -178,7 +178,7 @@ def test_initialize_mswin32_vc6
orig_ruby_so_name = RbConfig::CONFIG["RUBY_SO_NAME"]
RbConfig::CONFIG["RUBY_SO_NAME"] = "msvcrt-ruby18"

expected = ["x86", "mswin32", nil]
expected = ["x86", "mswin32", "60"]

platform = Gem::Platform.new "i386-mswin32"

Expand Down

0 comments on commit 718379d

Please sign in to comment.