[rubygems/rubygems] Remove unnecessary platform helpers

I think they add unnecessary indirection and inconsistency to the specs.

https://github.com/rubygems/rubygems/commit/609924d985
This commit is contained in:
David Rodríguez 2025-01-23 11:58:28 +01:00 committed by Hiroshi SHIBATA
parent 8ad7834796
commit 09b04fefb7
12 changed files with 33 additions and 75 deletions

View File

@ -111,11 +111,11 @@ RSpec.describe Bundler::LockfileParser do
end
let(:specs) do
[
Bundler::LazySpecification.new("peiji-san", v("1.2.0"), rb),
Bundler::LazySpecification.new("rake", v("10.3.2"), rb),
Bundler::LazySpecification.new("peiji-san", v("1.2.0"), Gem::Platform::RUBY),
Bundler::LazySpecification.new("rake", v("10.3.2"), Gem::Platform::RUBY),
]
end
let(:platforms) { [rb] }
let(:platforms) { [Gem::Platform::RUBY] }
let(:bundler_version) { Gem::Version.new("1.12.0.rc.2") }
let(:ruby_version) { "ruby 2.1.3p242" }
let(:lockfile_path) { Bundler.default_lockfile.relative_path_from(Dir.pwd) }

View File

@ -21,7 +21,7 @@ RSpec.describe Bundler::Source do
end
describe "#version_message" do
let(:spec) { double(:spec, name: "nokogiri", version: ">= 1.6", platform: rb) }
let(:spec) { double(:spec, name: "nokogiri", version: ">= 1.6", platform: Gem::Platform::RUBY) }
shared_examples_for "the lockfile specs are not relevant" do
it "should return a string with the spec name and version" do
@ -70,7 +70,7 @@ RSpec.describe Bundler::Source do
end
context "with a more recent version" do
let(:spec) { double(:spec, name: "nokogiri", version: "1.6.1", platform: rb) }
let(:spec) { double(:spec, name: "nokogiri", version: "1.6.1", platform: Gem::Platform::RUBY) }
let(:locked_gem) { double(:locked_gem, name: "nokogiri", version: "1.7.0") }
context "with color", :no_color_tty do
@ -97,7 +97,7 @@ RSpec.describe Bundler::Source do
end
context "with an older version" do
let(:spec) { double(:spec, name: "nokogiri", version: "1.7.1", platform: rb) }
let(:spec) { double(:spec, name: "nokogiri", version: "1.7.1", platform: Gem::Platform::RUBY) }
let(:locked_gem) { double(:locked_gem, name: "nokogiri", version: "1.7.0") }
context "with color", :no_color_tty do

View File

@ -281,7 +281,7 @@ RSpec.describe "bundle install with gem sources" do
end
it "installs gems for windows" do
simulate_platform x86_mswin32 do
simulate_platform "x86-mswin32" do
install_gemfile <<-G
source "https://gem.repo1"
gem "platform_specific"

View File

@ -765,7 +765,7 @@ RSpec.describe "bundle lock" do
bundle "lock --add-platform java x86-mingw32"
allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
expect(the_bundle.locked_platforms).to match_array(default_platform_list(java, x86_mingw32))
expect(the_bundle.locked_platforms).to match_array(default_platform_list("java", "x86-mingw32"))
end
it "supports adding new platforms, when most specific locked platform is not the current platform, and current resolve is not compatible with the target platform" do
@ -844,7 +844,7 @@ RSpec.describe "bundle lock" do
bundle "lock --add-platform java x86-mingw32"
allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
expect(the_bundle.locked_platforms).to contain_exactly(rb, linux, java, x86_mingw32)
expect(the_bundle.locked_platforms).to contain_exactly(Gem::Platform::RUBY, "x86_64-linux", "java", "x86-mingw32")
end
it "supports adding the `ruby` platform" do
@ -864,11 +864,11 @@ RSpec.describe "bundle lock" do
bundle "lock --add-platform java x86-mingw32"
allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
expect(the_bundle.locked_platforms).to match_array(default_platform_list(java, x86_mingw32))
expect(the_bundle.locked_platforms).to match_array(default_platform_list("java", "x86-mingw32"))
bundle "lock --remove-platform java"
expect(the_bundle.locked_platforms).to match_array(default_platform_list(x86_mingw32))
expect(the_bundle.locked_platforms).to match_array(default_platform_list("x86-mingw32"))
end
it "also cleans up redundant platform gems when removing platforms" do
@ -943,7 +943,7 @@ RSpec.describe "bundle lock" do
build_repo4 do
build_gem "ffi", "1.9.14"
build_gem "ffi", "1.9.14" do |s|
s.platform = x86_mingw32
s.platform = "x86-mingw32"
end
build_gem "gssapi", "0.1"
@ -975,7 +975,7 @@ RSpec.describe "bundle lock" do
gem "gssapi"
G
simulate_platform(x86_mingw32) { bundle :lock }
simulate_platform("x86-mingw32") { bundle :lock }
checksums = checksums_section_when_enabled do |c|
c.checksum gem_repo4, "ffi", "1.9.14", "x86-mingw32"

View File

@ -1132,7 +1132,7 @@ RSpec.describe "bundle update in more complicated situations" do
a
L
simulate_platform linux, &example
simulate_platform "x86_64-linux", &example
end
it "allows updating" do
@ -1173,7 +1173,7 @@ RSpec.describe "bundle update in more complicated situations" do
end
it "is not updated because it is not actually included in the bundle" do
simulate_platform linux do
simulate_platform "x86_64-linux" do
bundle "update a"
expect(last_command.stdboth).to include "Bundler attempted to update a but it was not considered because it is for a different platform from the current one"
expect(the_bundle).to_not include_gem "a"

View File

@ -178,7 +178,7 @@ RSpec.describe "bundle install from an existing gemspec" do
end
it "should match a lockfile without needing to re-resolve with development dependencies" do
simulate_platform java do
simulate_platform "java" do
build_lib("foo", path: tmp("foo")) do |s|
s.add_dependency "myrack"
s.add_development_dependency "thin"
@ -448,7 +448,7 @@ RSpec.describe "bundle install from an existing gemspec" do
simulate_new_machine
simulate_platform("jruby") { bundle "install" }
simulate_platform(x64_mingw32) { bundle "install" }
simulate_platform("x64-mingw32") { bundle "install" }
end
context "on ruby" do

View File

@ -195,7 +195,7 @@ RSpec.describe "bundle install across platforms" do
build_gem("ffi", "1.9.23")
end
simulate_platform java do
simulate_platform "java" do
install_gemfile <<-G
source "https://gem.repo4"
@ -330,7 +330,7 @@ RSpec.describe "bundle install across platforms" do
end
it "works with gems with platform-specific dependency having different requirements order" do
simulate_platform x64_mac do
simulate_platform "x86_64-darwin-15" do
update_repo2 do
build_gem "fspath", "3"
build_gem "image_optim_pack", "1.2.3" do |s|
@ -616,7 +616,7 @@ end
RSpec.describe "when a gem has no architecture" do
it "still installs correctly" do
simulate_platform x86_mswin32 do
simulate_platform "x86-mswin32" do
build_repo2 do
# The rcov gem is platform mswin32, but has no arch
build_gem "rcov" do |s|

View File

@ -367,9 +367,9 @@ RSpec.describe "bundle install with specific platforms" do
simulate_platform "x86_64-darwin-15" do
setup_multiplatform_gem
install_gemfile(google_protobuf)
bundle "lock --add-platform=#{x64_mingw32}"
bundle "lock --add-platform=x64-mingw32"
expect(the_bundle.locked_platforms).to include(x64_mingw32, "universal-darwin")
expect(the_bundle.locked_platforms).to include("x64-mingw32", "universal-darwin")
expect(the_bundle.locked_gems.specs.map(&:full_name)).to include(*%w[
google-protobuf-3.0.0.alpha.5.0.5.1-universal-darwin
google-protobuf-3.0.0.alpha.5.0.5.1-x64-mingw32
@ -381,9 +381,9 @@ RSpec.describe "bundle install with specific platforms" do
simulate_platform "x86_64-darwin-15" do
setup_multiplatform_gem
install_gemfile(google_protobuf)
bundle "lock --add-platform=#{java}"
bundle "lock --add-platform=java"
expect(the_bundle.locked_platforms).to include(java, "universal-darwin")
expect(the_bundle.locked_platforms).to include("java", "universal-darwin")
expect(the_bundle.locked_gems.specs.map(&:full_name)).to include(
"google-protobuf-3.0.0.alpha.5.0.5.1",
"google-protobuf-3.0.0.alpha.5.0.5.1-universal-darwin"

View File

@ -119,7 +119,7 @@ RSpec.describe "gemcutter's dependency API" do
end
it "falls back when the API errors out" do
simulate_platform x86_mswin32 do
simulate_platform "x86-mswin32" do
build_repo2 do
# The rcov gem is platform mswin32, but has no arch
build_gem "rcov" do |s|

View File

@ -606,13 +606,13 @@ RSpec.describe "bundle install with install-time dependencies" do
s.required_ruby_version = "> 9000"
end
build_gem "myrack", "1.2" do |s|
s.platform = x86_mingw32
s.platform = "x86-mingw32"
s.required_ruby_version = "> 9000"
end
build_gem "myrack", "1.2"
end
simulate_platform x86_mingw32 do
simulate_platform "x86-mingw32" do
install_gemfile <<-G, artifice: "compact_index"
ruby "#{Gem.ruby_version}"
source "https://gem.repo4"

View File

@ -370,7 +370,7 @@ RSpec.describe "Bundler.setup with multi platform stuff" do
end
it "allows specifying only-ruby-platform on windows with dependency platforms" do
simulate_platform x86_mswin32 do
simulate_platform "x86-mswin32" do
install_gemfile <<-G
source "https://gem.repo1"
gem "nokogiri", :platforms => [:windows, :mswin, :mswin64, :mingw, :x64_mingw, :jruby]
@ -397,7 +397,7 @@ RSpec.describe "Bundler.setup with multi platform stuff" do
G
bundle :lock
simulate_platform x86_mswin32 do
simulate_platform "x86-mswin32" do
bundle "config set force_ruby_platform true"
bundle "install"
@ -411,7 +411,7 @@ RSpec.describe "Bundler.setup with multi platform stuff" do
s.add_dependency "platform_specific"
end
end
simulate_platform x64_mingw32 do
simulate_platform "x64-mingw32" do
lockfile <<-L
GEM
remote: https://gem.repo2/
@ -438,10 +438,8 @@ RSpec.describe "Bundler.setup with multi platform stuff" do
end
end
%w[x86-mswin32 x64-mswin64 x86-mingw32 x64-mingw32 x64-mingw-ucrt].each do |arch|
it "allows specifying platform windows on #{arch} arch" do
platform = send(arch.tr("-", "_"))
%w[x86-mswin32 x64-mswin64 x86-mingw32 x64-mingw32 x64-mingw-ucrt].each do |platform|
it "allows specifying platform windows on #{platform} platform" do
simulate_platform platform do
lockfile <<-L
GEM

View File

@ -4,48 +4,8 @@ module Spec
module Platforms
include Bundler::GemHelpers
def rb
Gem::Platform::RUBY
end
def mac
"x86-darwin-10"
end
def x64_mac
"x86_64-darwin-15"
end
def java
"java"
end
def linux
"x86_64-linux"
end
def x86_mswin32
"x86-mswin32"
end
def x64_mswin64
"x64-mswin64"
end
def x86_mingw32
"x86-mingw32"
end
def x64_mingw32
"x64-mingw32"
end
def x64_mingw_ucrt
"x64-mingw-ucrt"
end
def not_local
generic_local_platform == rb ? java : rb
generic_local_platform == Gem::Platform::RUBY ? "java" : Gem::Platform::RUBY
end
def local_tag