From 22359cda1ce097c39804dfd7888c33eb12b42e71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 21 Jan 2025 10:28:57 +0100 Subject: [rubygems/rubygems] Refactor specs to use platform strings directly https://github.com/rubygems/rubygems/commit/d24c0c20e3 --- spec/bundler/commands/lock_spec.rb | 15 +++++--------- .../install/gemfile/specific_platform_spec.rb | 8 ++++---- spec/bundler/support/platforms.rb | 24 +++++++++++----------- spec/bundler/support/the_bundle.rb | 4 ++++ 4 files changed, 25 insertions(+), 26 deletions(-) diff --git a/spec/bundler/commands/lock_spec.rb b/spec/bundler/commands/lock_spec.rb index db600e356f..ffc2f21e24 100644 --- a/spec/bundler/commands/lock_spec.rb +++ b/spec/bundler/commands/lock_spec.rb @@ -765,8 +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) - lockfile = Bundler::LockfileParser.new(read_lockfile) - expect(lockfile.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 @@ -845,16 +844,14 @@ RSpec.describe "bundle lock" do bundle "lock --add-platform java x86-mingw32" allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile) - lockfile = Bundler::LockfileParser.new(read_lockfile) - expect(lockfile.platforms).to contain_exactly(rb, linux, java, x86_mingw32) + expect(the_bundle.locked_platforms).to contain_exactly(rb, linux, java, x86_mingw32) end it "supports adding the `ruby` platform" do bundle "lock --add-platform ruby" allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile) - lockfile = Bundler::LockfileParser.new(read_lockfile) - expect(lockfile.platforms).to match_array(default_platform_list("ruby")) + expect(the_bundle.locked_platforms).to match_array(default_platform_list("ruby")) end it "fails when adding an unknown platform" do @@ -867,13 +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) - lockfile = Bundler::LockfileParser.new(read_lockfile) - expect(lockfile.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" - lockfile = Bundler::LockfileParser.new(read_lockfile) - expect(lockfile.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 diff --git a/spec/bundler/install/gemfile/specific_platform_spec.rb b/spec/bundler/install/gemfile/specific_platform_spec.rb index 04495e2b72..c68ed9aafa 100644 --- a/spec/bundler/install/gemfile/specific_platform_spec.rb +++ b/spec/bundler/install/gemfile/specific_platform_spec.rb @@ -11,7 +11,7 @@ RSpec.describe "bundle install with specific platforms" do setup_multiplatform_gem install_gemfile(google_protobuf) allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile) - expect(the_bundle.locked_gems.platforms).to include(pl("x86_64-darwin-15")) + expect(the_bundle.locked_platforms).to include("universal-darwin") expect(the_bundle).to include_gem("google-protobuf 3.0.0.alpha.5.0.5.1 universal-darwin") expect(the_bundle.locked_gems.specs.map(&:full_name)).to include( "google-protobuf-3.0.0.alpha.5.0.5.1-universal-darwin" @@ -351,7 +351,7 @@ RSpec.describe "bundle install with specific platforms" do G allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile) - expect(the_bundle.locked_gems.platforms).to include(pl("x86_64-darwin-15")) + expect(the_bundle.locked_platforms).to include("universal-darwin") expect(the_bundle).to include_gems("facter 2.4.6 universal-darwin", "CFPropertyList 1.0") expect(the_bundle.locked_gems.specs.map(&:full_name)).to include("CFPropertyList-1.0", "facter-2.4.6-universal-darwin") @@ -369,7 +369,7 @@ RSpec.describe "bundle install with specific platforms" do install_gemfile(google_protobuf) bundle "lock --add-platform=#{x64_mingw32}" - expect(the_bundle.locked_gems.platforms).to include(x64_mingw32, pl("x86_64-darwin-15")) + 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 @@ -383,7 +383,7 @@ RSpec.describe "bundle install with specific platforms" do install_gemfile(google_protobuf) bundle "lock --add-platform=#{java}" - expect(the_bundle.locked_gems.platforms).to include(java, pl("x86_64-darwin-15")) + 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" diff --git a/spec/bundler/support/platforms.rb b/spec/bundler/support/platforms.rb index 526e1c09a9..567198f7cd 100644 --- a/spec/bundler/support/platforms.rb +++ b/spec/bundler/support/platforms.rb @@ -9,39 +9,39 @@ module Spec end def mac - Gem::Platform.new("x86-darwin-10") + "x86-darwin-10" end def x64_mac - Gem::Platform.new("x86_64-darwin-15") + "x86_64-darwin-15" end def java - Gem::Platform.new([nil, "java", nil]) + "java" end def linux - Gem::Platform.new("x86_64-linux") + "x86_64-linux" end def x86_mswin32 - Gem::Platform.new(["x86", "mswin32", nil]) + "x86-mswin32" end def x64_mswin64 - Gem::Platform.new(["x64", "mswin64", nil]) + "x64-mswin64" end def x86_mingw32 - Gem::Platform.new(["x86", "mingw32", nil]) + "x86-mingw32" end def x64_mingw32 - Gem::Platform.new(["x64", "mingw32", nil]) + "x64-mingw32" end def x64_mingw_ucrt - Gem::Platform.new(["x64", "mingw", "ucrt"]) + "x64-mingw-ucrt" end def windows_platforms @@ -53,7 +53,7 @@ module Spec end def not_local - all_platforms.find {|p| p != generic_local_platform } + all_platforms.find {|p| p != generic_local_platform.to_s } end def local_tag @@ -96,12 +96,12 @@ module Spec end def default_platform_list(*extra, defaults: default_locked_platforms) - defaults.concat(extra).uniq + defaults.concat(extra).map(&:to_s).uniq end def lockfile_platforms(*extra, defaults: default_locked_platforms) platforms = default_platform_list(*extra, defaults: defaults) - platforms.map(&:to_s).sort.join("\n ") + platforms.sort.join("\n ") end def default_locked_platforms diff --git a/spec/bundler/support/the_bundle.rb b/spec/bundler/support/the_bundle.rb index f252a4515b..4c2fb4d7bc 100644 --- a/spec/bundler/support/the_bundle.rb +++ b/spec/bundler/support/the_bundle.rb @@ -31,5 +31,9 @@ module Spec raise "Cannot read lockfile if it doesn't exist" unless locked? Bundler::LockfileParser.new(lockfile.read) end + + def locked_platforms + locked_gems.platforms.map(&:to_s) + end end end -- cgit v1.2.3