[rubygems/rubygems] Add Ruby 3.2 and 3.3 platforms to Gemfile DSL

Along the same lines as https://github.com/rubygems/rubygems/pull/5469,
this adds support for Ruby 3.2 and 3.3 platforms: `:ruby_32`, `mri_32`,
etc.

It also includes a spec that should help catch this earlier in the
future, failing if we don't support platforms for the version of Ruby
that is running the tests.

https://github.com/rubygems/rubygems/commit/7cd19d824d
This commit is contained in:
Daniel Colson 2023-02-05 22:09:40 -05:00 коммит произвёл git
Родитель 23052e005e
Коммит fd71a76f55
4 изменённых файлов: 25 добавлений и 4 удалений

Просмотреть файл

@ -22,6 +22,8 @@ module Bundler
2.7 2.7
3.0 3.0
3.1 3.1
3.2
3.3
].freeze ].freeze
KNOWN_MAJOR_VERSIONS = KNOWN_MINOR_VERSIONS.map {|v| v.split(".", 2).first }.uniq.freeze KNOWN_MAJOR_VERSIONS = KNOWN_MINOR_VERSIONS.map {|v| v.split(".", 2).first }.uniq.freeze

Просмотреть файл

@ -9,7 +9,7 @@ module Bundler
attr_reader :autorequire attr_reader :autorequire
attr_reader :groups, :platforms, :gemfile, :path, :git, :github, :branch, :ref attr_reader :groups, :platforms, :gemfile, :path, :git, :github, :branch, :ref
ALL_RUBY_VERSIONS = ((18..27).to_a + (30..31).to_a).freeze ALL_RUBY_VERSIONS = ((18..27).to_a + (30..33).to_a).freeze
PLATFORM_MAP = { PLATFORM_MAP = {
:ruby => [Gem::Platform::RUBY, ALL_RUBY_VERSIONS], :ruby => [Gem::Platform::RUBY, ALL_RUBY_VERSIONS],
:mri => [Gem::Platform::RUBY, ALL_RUBY_VERSIONS], :mri => [Gem::Platform::RUBY, ALL_RUBY_VERSIONS],

Просмотреть файл

@ -53,6 +53,8 @@ RSpec.describe Bundler::Dependency do
:ruby_27 => Gem::Platform::RUBY, :ruby_27 => Gem::Platform::RUBY,
:ruby_30 => Gem::Platform::RUBY, :ruby_30 => Gem::Platform::RUBY,
:ruby_31 => Gem::Platform::RUBY, :ruby_31 => Gem::Platform::RUBY,
:ruby_32 => Gem::Platform::RUBY,
:ruby_33 => Gem::Platform::RUBY,
:mri => Gem::Platform::RUBY, :mri => Gem::Platform::RUBY,
:mri_18 => Gem::Platform::RUBY, :mri_18 => Gem::Platform::RUBY,
:mri_19 => Gem::Platform::RUBY, :mri_19 => Gem::Platform::RUBY,
@ -66,6 +68,8 @@ RSpec.describe Bundler::Dependency do
:mri_27 => Gem::Platform::RUBY, :mri_27 => Gem::Platform::RUBY,
:mri_30 => Gem::Platform::RUBY, :mri_30 => Gem::Platform::RUBY,
:mri_31 => Gem::Platform::RUBY, :mri_31 => Gem::Platform::RUBY,
:mri_32 => Gem::Platform::RUBY,
:mri_33 => Gem::Platform::RUBY,
:rbx => Gem::Platform::RUBY, :rbx => Gem::Platform::RUBY,
:truffleruby => Gem::Platform::RUBY, :truffleruby => Gem::Platform::RUBY,
:jruby => Gem::Platform::JAVA, :jruby => Gem::Platform::JAVA,
@ -84,6 +88,8 @@ RSpec.describe Bundler::Dependency do
:windows_27 => Gem::Platform::WINDOWS, :windows_27 => Gem::Platform::WINDOWS,
:windows_30 => Gem::Platform::WINDOWS, :windows_30 => Gem::Platform::WINDOWS,
:windows_31 => Gem::Platform::WINDOWS, :windows_31 => Gem::Platform::WINDOWS,
:windows_32 => Gem::Platform::WINDOWS,
:windows_33 => Gem::Platform::WINDOWS,
:mswin => Gem::Platform::MSWIN, :mswin => Gem::Platform::MSWIN,
:mswin_18 => Gem::Platform::MSWIN, :mswin_18 => Gem::Platform::MSWIN,
:mswin_19 => Gem::Platform::MSWIN, :mswin_19 => Gem::Platform::MSWIN,
@ -97,6 +103,8 @@ RSpec.describe Bundler::Dependency do
:mswin_27 => Gem::Platform::MSWIN, :mswin_27 => Gem::Platform::MSWIN,
:mswin_30 => Gem::Platform::MSWIN, :mswin_30 => Gem::Platform::MSWIN,
:mswin_31 => Gem::Platform::MSWIN, :mswin_31 => Gem::Platform::MSWIN,
:mswin_32 => Gem::Platform::MSWIN,
:mswin_33 => Gem::Platform::MSWIN,
:mswin64 => Gem::Platform::MSWIN64, :mswin64 => Gem::Platform::MSWIN64,
:mswin64_19 => Gem::Platform::MSWIN64, :mswin64_19 => Gem::Platform::MSWIN64,
:mswin64_20 => Gem::Platform::MSWIN64, :mswin64_20 => Gem::Platform::MSWIN64,
@ -109,6 +117,8 @@ RSpec.describe Bundler::Dependency do
:mswin64_27 => Gem::Platform::MSWIN64, :mswin64_27 => Gem::Platform::MSWIN64,
:mswin64_30 => Gem::Platform::MSWIN64, :mswin64_30 => Gem::Platform::MSWIN64,
:mswin64_31 => Gem::Platform::MSWIN64, :mswin64_31 => Gem::Platform::MSWIN64,
:mswin64_32 => Gem::Platform::MSWIN64,
:mswin64_33 => Gem::Platform::MSWIN64,
:mingw => Gem::Platform::MINGW, :mingw => Gem::Platform::MINGW,
:mingw_18 => Gem::Platform::MINGW, :mingw_18 => Gem::Platform::MINGW,
:mingw_19 => Gem::Platform::MINGW, :mingw_19 => Gem::Platform::MINGW,
@ -122,6 +132,8 @@ RSpec.describe Bundler::Dependency do
:mingw_27 => Gem::Platform::MINGW, :mingw_27 => Gem::Platform::MINGW,
:mingw_30 => Gem::Platform::MINGW, :mingw_30 => Gem::Platform::MINGW,
:mingw_31 => Gem::Platform::MINGW, :mingw_31 => Gem::Platform::MINGW,
:mingw_32 => Gem::Platform::MINGW,
:mingw_33 => Gem::Platform::MINGW,
:x64_mingw => Gem::Platform::X64_MINGW, :x64_mingw => Gem::Platform::X64_MINGW,
:x64_mingw_20 => Gem::Platform::X64_MINGW, :x64_mingw_20 => Gem::Platform::X64_MINGW,
:x64_mingw_21 => Gem::Platform::X64_MINGW, :x64_mingw_21 => Gem::Platform::X64_MINGW,
@ -132,7 +144,9 @@ RSpec.describe Bundler::Dependency do
:x64_mingw_26 => Gem::Platform::X64_MINGW, :x64_mingw_26 => Gem::Platform::X64_MINGW,
:x64_mingw_27 => Gem::Platform::X64_MINGW, :x64_mingw_27 => Gem::Platform::X64_MINGW,
:x64_mingw_30 => Gem::Platform::X64_MINGW, :x64_mingw_30 => Gem::Platform::X64_MINGW,
:x64_mingw_31 => Gem::Platform::X64_MINGW } :x64_mingw_31 => Gem::Platform::X64_MINGW,
:x64_mingw_32 => Gem::Platform::X64_MINGW,
:x64_mingw_33 => Gem::Platform::X64_MINGW }
end end
# rubocop:enable Naming/VariableNumber # rubocop:enable Naming/VariableNumber

Просмотреть файл

@ -139,14 +139,19 @@ RSpec.describe Bundler::Dsl do
describe "#gem" do describe "#gem" do
# rubocop:disable Naming/VariableNumber # rubocop:disable Naming/VariableNumber
[:ruby, :ruby_18, :ruby_19, :ruby_20, :ruby_21, :ruby_22, :ruby_23, :ruby_24, :ruby_25, :ruby_26, :ruby_27, [:ruby, :ruby_18, :ruby_19, :ruby_20, :ruby_21, :ruby_22, :ruby_23, :ruby_24, :ruby_25, :ruby_26, :ruby_27,
:ruby_30, :ruby_31, :mri, :mri_18, :mri_19, :mri_20, :mri_21, :mri_22, :mri_23, :mri_24, :mri_25, :mri_26, :ruby_30, :ruby_31, :ruby_32, :ruby_33, :mri, :mri_18, :mri_19, :mri_20, :mri_21, :mri_22, :mri_23, :mri_24,
:mri_27, :mri_30, :mri_31, :jruby, :rbx, :truffleruby].each do |platform| :mri_25, :mri_26, :mri_27, :mri_30, :mri_31, :mri_32, :mri_33, :jruby, :rbx, :truffleruby].each do |platform|
it "allows #{platform} as a valid platform" do it "allows #{platform} as a valid platform" do
subject.gem("foo", :platform => platform) subject.gem("foo", :platform => platform)
end end
end end
# rubocop:enable Naming/VariableNumber # rubocop:enable Naming/VariableNumber
it "allows platforms matching the running Ruby version" do
platform = "ruby_#{RbConfig::CONFIG["MAJOR"]}#{RbConfig::CONFIG["MINOR"]}"
subject.gem("foo", :platform => platform)
end
it "rejects invalid platforms" do it "rejects invalid platforms" do
expect { subject.gem("foo", :platform => :bogus) }. expect { subject.gem("foo", :platform => :bogus) }.
to raise_error(Bundler::GemfileError, /is not a valid platform/) to raise_error(Bundler::GemfileError, /is not a valid platform/)